To my knowledge you can only use one JDK version for one Tomcat instance. But this doesn't necessarily mean that you can't run a Java web application which was compiled for Java 5 in a Tomcat server running with Java 6. Maybe there are some tricks or obstacles you have to know but the easiest way would be to give it a try. That means you should compile your application with target version 5 or 1.5 and simply deploy the project into a Tomcat running with on Java 6.
One thing which could become a problem could be the compilation of JSPs because they would get compiled into servlets with Java 6 by Tomcat. I'm not sure if this really IS a problem.

Of course a cleaner solution would be to migrate your application to Java 6 or to run multiple instances of Tomcat, i.e. Tomcat 5 with Java 5 for the one application and Tomcat 6 with Java 6 for the other. In the long run it could pay off to update the application itself (if possible) because it's obviously more work to provide and manage different versions and instances of Tomcat.

It would help if you told us *why* you want to use different JRE versions. As Marco said, Java does a very good job at backwards compatibility, and just about any app developed with Java 5 runs without problems in a Java 6 JRE.

ishan dave
Ranch Hand

Joined: Apr 16, 2007
Posts: 39

posted Jan 30, 2010 04:22:07

0

Dear Marco,

Thank you for your inputs, Well definitely we are the process to upgrade our application but mean while we don't want it to stop so for the temporary solution I go for the two instances of Tomcat.

so will you please help me out that how can I configure to instance, I mean how can I ask Server1 to point to Java5 and server2 to point to java6.

Thank you in advance.

Dear Ulf,

Actually I faced some problems with sql.Date and some request handling stuffs, again I am testing my application for both the versions.

And in fact the solution provided by Marco sounds good to fulfil my present requirements.

Well, since you are really experiencing incompatibility issues during the migration process it may make sense to use two Tomcat versions meanwhile.

Basically you have to take care that each Tomcat uses a few ports (depending on the configuration). So you have to deal with conflicting ports, i.e. choose different one for each Tomcat instance, if you plan to run Tomcat on the same machine.

If you have a look at the Tomcat startup script in $TOMCAT_HOME/bin/catalina.sh you will quickly see that Tomcat recognizes quite some environment variables. So usually it should be enough to point JAVA_HOME and JRE_HOME to right JDK location in your init script or before you startup Tomcat. Depending on your OS and/or Linux distribution the startup and initialization process might work slightly different but the basics should be as described.

I hope this helps to solve your problem!

Additional note: According to the Tomcat documentation Tomcat 6 should be able to run with Java 5 and 6! So at least you don't have to deal with different Tomcat versions to use Java 5 and Java 6.

Marco

ishan dave
Ranch Hand

Joined: Apr 16, 2007
Posts: 39

posted Jan 30, 2010 05:26:33

0

Marco Ehrentreich wrote:Well, since you are really experiencing incompatibility issues during the migration process it may make sense to use two Tomcat versions meanwhile.

Basically you have to take care that each Tomcat uses a few ports (depending on the configuration). So you have to deal with conflicting ports, i.e. choose different one for each Tomcat instance, if you plan to run Tomcat on the same machine.

If you have a look at the Tomcat startup script in $TOMCAT_HOME/bin/catalina.sh you will quickly see that Tomcat recognizes quite some environment variables. So usually it should be enough to point JAVA_HOME and JRE_HOME to right JDK location in your init script or before you startup Tomcat. Depending on your OS and/or Linux distribution the startup and initialization process might work slightly different but the basics should be as described.

I hope this helps to solve your problem!

Additional note: According to the Tomcat documentation Tomcat 6 should be able to run with Java 5 and 6! So at least you don't have to deal with different Tomcat versions to use Java 5 and Java 6.

I hope everything works out as described but having worked quite a lot with Tomcat in different versions and with multiple instances running in parallel, I'm confident that there should be at most minor problems. If it doesn't work just feel free to ask for help.