tags:

views:

690

answers:

1

I have 2 Java Web Projects. One runs on JDK 1.5 and the other runs on JDK 1.6. I want to run both of them on the same computer, but the JAVA_HOME environment variable can only have one value. I want to set JAVA_HOME for each Tomcat server

Please help me to solve my problem.

+2  A: 

One thing that you could do would be to modify the catalina.sh (Unix based) or the catalina.bat (windows based).

Within each of the scripts you can set certain variables which only processes created under the shell will inherit. So for catalina.sh, use the following line:

export JAVA_HOME="intented java home"

And for windows use

set JAVA_HOME="intented java home"
bogertron
Isn't the windows version supposed to differ from the unix version? I'm no batch guy, but I thought it was `set`, or am I dating myself?
Ry4an
I'm using Windows XP and I have added line "export JAVA_HOME="C:\Program Files\Java\jdk1.6.0_12" at the beginning of file Tomcat/bin/catalina.batBut Tomcat can not startHerr is a part of my filerem Guess CATALINA_HOME if not definedexport JAVA_HOME="C:\Program Files\Java\jdk1.6.0_12"set JAVA_OPTS=%JAVA_OPTS% -Xmx512mset CURRENT_DIR=%cd%if not "%CATALINA_HOME%" == "" goto gotHomeset CATALINA_HOME=%CURRENT_DIR%if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
Chan Pye
Ah. Evil use of the copy paste! I did not mean to put export for the windows version. Ry4an was correct in that set is the correct command. Updating the answer.
bogertron
Thanks for your help, I have solved my poblemWe have to use set command and vaule of JAVA_HOME with be a String without " character (set JAVA_HOME = C:\Program Files\Java\jdk1.6.0_12 )
Chan Pye