How to set JAVA_HOME for multiple Tomcat instances?

前端 未结 11 1044
情话喂你
情话喂你 2020-12-14 06:29

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 on

相关标签:
11条回答
  • 2020-12-14 06:37

    place a setenv.sh in the the bin directory with

    JAVA_HOME=/usr/java/jdk1.6.0_43/
    JRE_HOME=/usr/java/jdk1.6.0_43/jre
    

    or an other version your running.

    0 讨论(0)
  • 2020-12-14 06:41

    Just a note...

    If you add that code to setclasspath.bat or setclasspath.sh, it will actually be used by all of Tomcat's scripts you could run, rather than just Catalina.

    The method for setting the variable is as the other's have described.

    0 讨论(0)
  • 2020-12-14 06:42

    For Debian distro we can override the setting via defaults

    /etc/default/tomcat6
    

    Set the JAVA_HOME pointing to the java version you want.

    JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
    
    0 讨论(0)
  • 2020-12-14 06:43

    I had the same problem my OS is windows 8 and I am using Tomcat 8, I just edited the setclasspath.bat file in bin folder and set JAVA_HOME and JRE_HOME like this...

    @echo off
    ...
    ...
    set "JRE_HOME=%ProgramFiles%\Java\jre8"
    set "JAVA_HOME=%ProgramFiles%\Java\jdk1.7.0_03"
    ...
    ...

    and it works fine for me now......

    0 讨论(0)
  • 2020-12-14 06:45

    You can add setenv.sh in the the bin directory with:

    export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")

    and it will dynamically change when you update your packages.

    0 讨论(0)
  • 2020-12-14 06:47

    Also, note that there shouldn't be any space after =:

    set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_27
    
    0 讨论(0)
提交回复
热议问题