3

So I'm running apache tomcat 9, when I check the /manager page it shows the jvm version as 11.0.8+10-post-Ubuntu-0ubuntu118.04.1.

I want to use Java version 8, how would I change this?

I have read around online and could not find anything that works.

OS: ubuntu 18.04

It's not a duplicate because I have read that post already and I found the answers unhelpful / not working. (Also that thread is targeted toward the windows OS as I'm based on Ubuntu (CLI only).)

Cardstdani
  • 4,999
  • 3
  • 12
  • 31
user12346306
  • 47
  • 1
  • 1
  • 8

2 Answers2

4

There are multiple ways of doing so.

  1. Chaining global JAVA_HOME environment variables to the java you wish to use. Note that this will change Java for all apps running on that machine.

  2. Using setenv file. In CATALINA_BASE/bin directory open or create file named setenv.sh and put JAVA_HOME=/usr/lib/jvm/openjdk-8-jdk in it. This will change it only for your tomcat. Please note to change it to the JDK/JRE you want to use.

Pavel Polivka
  • 858
  • 4
  • 22
1

Using the "setenv" script (optional, recommended)

Apart from CATALINA_HOME and CATALINA_BASE, all environment variables can be specified in the "setenv" script. The script is placed either into CATALINA_BASE/bin or into CATALINA_HOME/bin directory and is named setenv.bat (on Windows) or setenv.sh (on *nix). The file has to be readable.

By default the setenv script file is absent. If the script file is present both in CATALINA_BASE and in CATALINA_HOME, the one in CATALINA_BASE is preferred.

For example, to configure the JRE_HOME and CATALINA_PID variables you can create the following script file:

On *nix, $CATALINA_BASE/bin/setenv.sh:

JRE_HOME=/usr/java/latest CATALINA_PID="$CATALINA_BASE/tomcat.pid"

http://tomcat.apache.org/tomcat-9.0-doc/RUNNING.txt

vamsikurre
  • 309
  • 3
  • 5