How to change Java version used by TOMCAT?

前端 未结 7 991
时光说笑
时光说笑 2020-11-27 18:40

I have Java 1.6 and Tomcat 5.5 installed on my system.

But Tomcat 5.5 accesses Java 1.5 and hence as the outcome I get the error Bad version number in .class f

7条回答
  •  情歌与酒
    2020-11-27 18:49

    If you use the standard scripts to launch Tomcat (i.e. you haven't installed Tomcat as a windows service), you can use the setenv.bat file, to set your JRE_HOME version.

    On Windows, create the file %CATALINA_BASE%\bin\setenv.bat, with content:

    set "JRE_HOME=%ProgramFiles%\Java\jre1.6.0_20"

    exit /b 0

    And that should be it.

    You can test this using %CATALINA_BASE%\bin\configtest.bat (Disclaimer: I've only checked this with a Tomcat7 installation).

    Further Reading:

    • http://tomcat.apache.org/tomcat-5.5-doc/RUNNING.txt - Section: 'Advanced Configuration - Multiple Tomcat Instances'
    • http://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt - Section: '(3.4) Using the "setenv" script (optional, recommended)'

提交回复
热议问题