I want to run my Tomcat with Java 7 but all I found about configuring it doesn't work. The management interface of Tomcat shows 1.6.0_24-b24
as Java version. The JAVA_HOME
variable is empty.
% echo $JAVA_HOME
I understand that in this case Tomcat uses the system default Java, which should be 7.
% java -version
java version "1.7.0_09"
OpenJDK Runtime Environment (IcedTea7 2.3.3) (7u9-2.3.3-0ubuntu1~12.04.1)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
I changed it with update-alternatives
.
What part of the configuration am I missing?
3 Answers 3
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.
-
Yup, this is right. On most systems, you don't have access to the tomcat user in a way you can set JAVA_HOME. You have two choices: change the Java in use by the whole system to a single one or tweak it the way you show here.Russ Bateman– Russ Bateman2013年07月12日 15:48:49 +00:00Commented Jul 12, 2013 at 15:48
export JAVA_HOME=/path/to/your/java/environment Then run tomcat.
You can do this in the users .bash_profile as well.
-
1This doesn't work either. Set it to
/usr/lib/jvm/java-1.7.0-openjdk-amd64
which is now shown byecho $JAVA_HOME
as well assudo -u tomcat7 echo $JAVA_HOME
. Tomcat still starts with the wrong version.André Stannek– André Stannek2012年11月02日 10:24:55 +00:00Commented Nov 2, 2012 at 10:24 -
I can confirm that this does not help. Even if you put JAVA_HOME=your new java in the /etc/environment and reboot, and do the alternatives thing, tomcat still picks up the old version.John Little– John Little2016年06月15日 15:40:54 +00:00Commented Jun 15, 2016 at 15:40
I had the same issue. I am using tomcat 9. I decided to define the configurations in catalina.sh.
This is however for *nix
$ cd /apache-tomcat-9.0.21/bin/
$ vim catalina.sh
JAVA_HOME=/usr/lib/jvm/jdk-11.0.12
JRE_HOME=/usr/lib/jvm/jdk-11.0.12
ensure to restart your tomcat
$ ./startup.sh
-
2Modifying
catalina.sh
is not a good idea (it might get overwritten by an upgrade). Create asetenv.sh
file in the same directory (it is sourced bycatalina.sh
whenever present).Piotr P. Karwasz– Piotr P. Karwasz2021年08月30日 09:17:50 +00:00Commented Aug 30, 2021 at 9:17
update-java-alternatives
will update all java related alternatives.