简体   繁体   中英

Maven, Tomcat and Java_Home / JRE_home variable

When I was trying to install Tomcat as a service, I kept getting the

"JAVA_HOME environment variable is not defined"

error even though my Java_Home was set to my jre. I tried putting my JDK, then updated my Java and put my new JRE, then what solved the problem was erasing the Java_Home variable, setting the JRE_HOME variable to the JRE (C:\\Program Files\\Java\\jre-9.0.1) and then restarting. And the error finally went away and I could install/run Tomcat as a service.

But now I'm trying to use Maven, and before, it used to allow me to make maven projects, but now, because I deleted my Java_Home variable, I'm getting this error:

"JAVA_HOME not found in your environment. Please set the JAVA_HOME variable in your environment to match the location of your Java installation"

So I'm looking at the files in the maven directory, and the one called mvn.cmd has this:

@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome

and also

:OkJHome
if exist "%JRE_HOME%\bin\java.exe" goto chkMHome

So i'm really confused at how to fix this problem if my JRE_Home is set, and if my JAVA_HOME is not defined, it should be using my JRE_Home but maven isn't.

And if my JRE_Home is working for Tomcat, what do I need to do to get Maven to accept it?

Set the environment variable JAVA_HOME to (DRIVE):\\Program Files\\Java\\jdk & set the JRE_HOME variable to (DRIVE):\\Program Files\\Java\\jre\\bin

You're all set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM