Java version for Tomcat

11,740

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.

Share:
11,740

Related videos on Youtube

André Stannek
Author by

André Stannek

Updated on September 18, 2022

Comments

  • André Stannek
    André Stannek over 1 year

    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?

    • Admin
      Admin over 11 years
      The command update-java-alternatives will update all java related alternatives.
    • Admin
      Admin over 11 years
      Did do it. Sadly no changes :-(
  • André Stannek
    André Stannek over 11 years
    This doesn't work either. Set it to /usr/lib/jvm/java-1.7.0-openjdk-amd64 which is now shown by echo $JAVA_HOME as well as sudo -u tomcat7 echo $JAVA_HOME. Tomcat still starts with the wrong version.
  • user4292106
    user4292106 almost 11 years
    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.
  • John Little
    John Little almost 8 years
    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.
  • Piotr P. Karwasz
    Piotr P. Karwasz over 2 years
    Modifying catalina.sh is not a good idea (it might get overwritten by an upgrade). Create a setenv.sh file in the same directory (it is sourced by catalina.sh whenever present).