Neither the java_home nor the jre_home environment variable is defined error Solution

Source: Internet
Author: User

The reason is that later versions of JDK (such as jdk1.6) will not automatically register the environment variables java_home and jre_home after installation. Like my environment in the unit, My users are restricted (poweruser) and it is not convenient to set environment variables, so I found another method.

 

Let's first look at Tomcat's startup. bat, which calls Catalina. bat, While Catalina. Bat calls setclasspath. bat. You only need to declare the environment variables at the beginning of setclasspath. bat. For example, my environment variables are:

 

Rem ---------------------------------------------------------------------------
Rem set classpath and Java options
Rem
Rem $ ID: setclasspath. Bat 505241 10: 22: 58z jfclere $
Rem ---------------------------------------------------------------------------

Set java_home = D: \ Java \ jdk1.6.0 _ 11
Set jre_home = D: \ Java \ jre6

Rem make sure prerequisite environment variables are set
If not "% java_home %" = "" Goto gotjdkhome
If not "% jre_home %" = "" Goto gotjrehome
Echo neither the java_home nor the jre_home environment variable is defined
Echo at least on E of these environment variable is needed to run this program
Goto exit
......

 

In this way, java_home and jre_home are registered every time you run startup. bat. When the console window is closed, the two variables will disappear and will no longer occupy the memory. Run it, and the final prompt is displayed."Information: server startup in XXXXX ms"This is all done.

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.