File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes How set java path for a perticular apache server ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How set java path for a perticular apache server ?" Watch "How set java path for a perticular apache server ?" New topic
Author

How set java path for a perticular apache server ?

ishan dave
Ranch Hand

Joined: Apr 16, 2007
Posts: 39
hi,

I want two jres in my computer i.e. jre 1.5 and jre 1.6.

Now there are web applications one developed with 1.5 and one with 1.6 lets say application5 and appliation6.

Now I want to configure these applications in such a way that application5 will refer to jre 1.5 and application6 will refer to jre 1.6, both this applications are running on same apache server.

or does it possible to have to different instances of apache each referring to different jre and then deploy the respective application in that.

will you please help me to solve this problem,

Thank you,
Ishaan
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

Hi Ishaan,

I guess with "Apache server" you mean Apache Tomcat?

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.

Marco
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
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
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.

Thank you,
Ishaan
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

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
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.

Marco


Dear Marco,

Thank you very very much.

You really provide me the solution which I am looking for.

Thank you again,
Ishaan
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

You're welcome

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.

Marco
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How set java path for a perticular apache server ?