tomcat sets the specified jdk to run

quote


One of tomcat: Specify the JDK version of

tomcat when tomcat is running as the web application server for daily development, which brings a lot of convenience to development and testing. The operation of tomcat depends on the support of JDK. When installing JDK, environment variables are often configured: JAVA_HOME, CLASSPAT, And need to add the path variable. When deploying applications to tomcat, most do not need to modify the running environment, but sometimes it is necessary to modify the JDK version. From the JDK version that can be modified when tomcat is running, we can know that JDK environment variables must be configured from time to time when using tomcat, because we can By modifying the tomcat file, specify the JDK version of the tomcat runtime. The following explains how to modify the JDK version windows

when tomcat is running: 1. Unzip the downloaded tomcat; 2. Find the setclasspath.bat file under bin; add the following code at the beginning of the file: set JAVA_HOME=D:\Program Files\Java\jdk7\ jdk1.7.0_51 set JRE_HOME=D:\Program Files\Java\jdk7\jre7 The above means to set the path of JAVA_HOME and JRE_HOME; through this we can see that the environment variable of JDK can not be set; linux find setclasspath under bin .sh, add the following code at the beginning of the file: set JAVA_HOME=/home/jdk/Java\jdk7\jdk1.7.0_51 set JRE_HOME=/home/jdk/Java\jdk7\jre7





















After modifying the setclasspath file, tomcat uses the set JDK at startup.

But why does it work after setting it this way?

We all know that we can start tomcat by running startup.bat under bin, startup.bat will call catalina.bat file, and catalina.bat will call setclasspath.bat file to get the values ​​of the two environment variables JAVA_HOME and JRE_HOME, so if To point to a specific JDK when tomcat starts, add JAVA_HOME and JRE_HOME at the beginning of the setclasspath.bat file.

Based on the above operation mode, there is a second modification method, as follows:

1. Modify tomcat/bin/catalina.bat and add set JAVA_HOME=D:\Program Files\Java\jdk7\jdk1.7.0_51

2. Modify tomcat/ bin/setclasspath.bat, also add

set JAVA_HOME=D:\Program Files\Java\jdk7\jdk1.7.0_51

set JRE_HOME=D:\Program Files\Java\jdk7\jre7



These two methods can be implemented using either method Modify the JDK environment that tomcat depends on, and you can not configure the JDK environment variables.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326226763&siteId=291194637