When you open catalina.sh / catalina.bat, you can see :
Environment Variable Prequisites
JAVA_HOME Must point at your Java Development Kit installation.
So, set your environment variable JAVA_HOME to point to Java 6. Also make sure JRE_HOME is pointing to the same target, if it is set.
Update: since you are on Windows, see here for how to manage your environment variables
Answer from Bozho on Stack OverflowWhen you open catalina.sh / catalina.bat, you can see :
Environment Variable Prequisites
JAVA_HOME Must point at your Java Development Kit installation.
So, set your environment variable JAVA_HOME to point to Java 6. Also make sure JRE_HOME is pointing to the same target, if it is set.
Update: since you are on Windows, see here for how to manage your environment variables
You can change the JDK or JRE location using the following steps:
- Open the terminal or cmd.
- Go to the
[tomcat-home]\bindirectory.
ex:c:\tomcat8\bin - Write the following
command:
Tomcat8W //ES//Tomcat8 - Dialog will open, select the Java tab (top pane).
- Change the Java Virtual Machine value.
- Click OK.
Note:
In Apache TomEE same steps, but step (3) the command must be: TomEE //ES
Finally found the right configuration file my self. It is /etc/default/tomcat. There I was able to set
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
and it works now.
Thanks for the help.
export JAVA_HOME=/path/to/your/java/environment Then run tomcat.
You can do this in the users .bash_profile as well.
Videos
You can try this:
Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command below.
gksudo gedit /etc/default/tomcat7
When the file opens, uncomment the line that sets the JAVA_HOME variable.

Save and restart tomcat7 server.
Tomcat will not actually use your JAVA_HOME environmente variable, but look in some predefined locations and in the JAVA_HOME variable set inside the startup script, as other answers point out. If you don't like messing with the tomcat startup script, you could create a symlink for your preferred java installation, which will be picked up by tomcat.
For example:
ln -s /usr/lib/jvm/java-8-oracle /usr/lib/jvm/default-java
There are multiple ways of doing so.
Chaining global
JAVA_HOMEenvironment variables to the java you wish to use. Note that this will change Java for all apps running on that machine.Using setenv file. In
CATALINA_BASE/bindirectory open or create file namedsetenv.shand putJAVA_HOME=/usr/lib/jvm/openjdk-8-jdkin it. This will change it only for your tomcat. Please note to change it to the JDK/JRE you want to use.
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