How to change Tomcat to use JDK 7
By:Roy.LiuLast updated:2019-08-17
The current environment is using Tomcat 7 + JDK 6. How to configure Tomcat to use JDK 7?
Environment
- Tomcat 7 (apt-get install)
- Debian 7.5
- JDK 6 and JDK 7
P.S Tomcat 7 is installed via apt-get
Note
You may interest at this tutorial – Apache Tomcat 8 + JDK 8 on Debian
You may interest at this tutorial – Apache Tomcat 8 + JDK 8 on Debian
1. Solution
Update the JAVA_HOME in this file /etc/default/tomcat7
1.1 Edit /etc/default/tomcat7, update JAVA_HOME
$ sudo vim /etc/default/tomcat7
/etc/default/tomcat7
#... # The home directory of the Java development kit (JDK). You need at least # JDK version 1.5. If JAVA_HOME is not set, some common directories for # OpenJDK, the Sun JDK, and various J2SE 1.5 versions are tried. #JAVA_HOME=/usr/lib/jvm/openjdk-6-jdk JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 #...
1.2 Restart Tomcat, done.
$ sudo service tomcat7 restart
1.3 Check this article to find out which JDK is used by Tomcat.
No SPACE, What the F!
Make sure there is no extra space between the equal symbol “=”, it will cause “JAVA_HOME no found”, I spent hours fixing this bug!
Make sure there is no extra space between the equal symbol “=”, it will cause “JAVA_HOME no found”, I spent hours fixing this bug!
For example
/etc/default/tomcat7
#...Wrong, SPACE JAVA_HOME = /usr/lib/jvm/java-7-openjdk-amd64 #...Correct JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
References
From:一号门
COMMENTS