Tomcat: Specifies the JDK version when tomcat is running and the tomcat JDK version.
Tomcat, as the web application server for daily development, has brought a lot of convenience for development and testing. tomcat depends on JDK support for running. During JDK installation, environment variables such as JAVA_HOME and CLASSPAT are often configured, add the path variable. When deploying an application to tomcat, most of them do not need to modify the runtime environment, but sometimes they need to modify the JDK version. You can modify the JDK version when tomcat is running, we can know that JDK environment variables must be configured from time to time when tomcat is used, because we can specify the JDK version when tomcat is running by modifying the tomcat file.
The following describes how to modify the JDK version when tomcat is running.
Windows
1. decompress 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_51set JRE_HOME=D:\Program Files\Java\jdk7\jre7
The above indicates setting the JAVA_HOME and JRE_HOME paths;
Here we can see that JDK environment variables are not set;
Linux
Find setclasspath. sh in bin and add the following code at the beginning of the file:
set JAVA_HOME=/home/jdk/Java\jdk7\jdk1.7.0_51set JRE_HOME=/home/jdk/Java\jdk7\jre7
After the setclasspath file is modified, tomcat uses the set JDK at startup.
But why is it possible after this setting?
We all know that tomcat can be started by running startup in bin. bat, startup. bat will call catalina. bat file, While catalina. bat will call setclasspath. the bat file is used to obtain the values of the JAVA_HOME and JRE_HOME environment variables. Therefore, to point to a specific JDK at tomcat startup. add JAVA_HOME and JRE_HOME at the beginning of the bat file.
Based on the preceding running method, there is also a second modification method, as shown below:
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 and add
Set JAVA_HOME = D: \ Program Files \ Java \ jdk7 \ jdk1.7.0 _ 51
Set JRE_HOME = D: \ Program Files \ Java \ jdk7 \ jre7
Either of the two methods can be used to modify tomcat's dependent JDK environment without configuring JDK environment variables.
Correct the error. Thank you!