Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat6 and Java 7

In linux, is it possible to have a web application written using Java 7 be deployed on tomcat6? If so, what configuration needs to be modified to allow it to work?

I have tried changing the JAVA_HOME variable in the tomcat6.conf file and restarting, but it is still using 1.6 according to the tomcat manager webpage, and only applications written in 1.6 or lower deploy correctly.

I have both jdk 1.6 and 1.7 installed in different locations.

like image 218
Zero Avatar asked Mar 06 '12 22:03

Zero


3 Answers

I had a major problem when I compiled my servlet using java JDK 1.7.0, Tomcat wouldn't start up due of a runtime manor.major version error.

To make Tomcat6 run your classes using JDK 1.7 do the following:

  1. Open the file /etc/init.d/tomcat6 with root privilege.

  2. You will find a variable called JDK_DIRS at line 83.

  3. Comment it out by adding # at the beginning of the line.

  4. Write the following bellow it: JDK_DIRS="/usr/lib/jvm/java-1.7.0-openjdk-i386"

  5. Save and restart tomcat

like image 156
Ramzi Komati Avatar answered Oct 21 '22 14:10

Ramzi Komati


I'm just using default Tomcat installations without setting up any config files except the tomcat-users.xml for GUI login.

Apache Tomcat 6.0.35 and 6.0.16 are each running on JVM 1.7.0_03-b05 (Windows+Linux).

JAVA_HOME must point to the JDK folder; e.g.:

C:\Program Files\Java\jdk1.7 (Windows)

or

/usr/lib/jvm/java-6-sun (Ubuntu, this link points to JDK installation)

like image 24
eldiamo Avatar answered Oct 21 '22 14:10

eldiamo


I have run into similar problem and it seems that JDK 1.7 doesn't have backward compatibility with Tomcat 6. You need to deploy it to Tomcat 7 or recompile using JDK 1.6.

like image 25
aretai Avatar answered Oct 21 '22 15:10

aretai