Tomcat: Specifies the JDK version when tomcat is running and the tomcat JDK version.

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.