简体   繁体   中英

Eclipse: JAVA_HOME not set

The system cannot find the path specified.
JAVA HOME is not set correctly.

I am getting the following error when I try to run web server in Eclipse:

The system cannot find the path specified. JAVA HOME is not set correctly.

But checking my env variables they look correct:

echo %JAVA_HOME%
C:\Program Files (x86)\Java\jdk1.8.0_101

echo %PATH%
C:\ProgramData\Oracle\Java\javapath;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;C:\Program Files\Git\cmd;C:\HashiCorp\Vagrant\bin;C:\Installation;C:\Program Files (x86)\Brackets\command;C:\Program Files (x86)\Java\jdk1.8.0_101\bin;C:\ProgramData\Oracle\Java\javapath;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;C:\Program Files\Git\cmd;C:\HashiCorp\Vagrant\bin;C:\Installation;C:\Program Files (x86)\Brackets\command;C:\Program Files (x86)\Java\jdk1.8.0_101\bin;C:\ProgramData\Oracle\Java\javapath;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;C:\Program Files\Git\cmd;C:\HashiCorp\Vagrant\bin;C:\Installation;C:\Program Files (x86)\Brackets\command;

Is there something else I'm missing?

Check for system environment variables and user environment variables... seems like eclipse is taking variables from different environment..

If problem persist then set the JAVA_HOME in eclipse to tell eclipse explicitly where java is installed in the system. To set JAVA_HOME in eclispe few options given below.

To set JAVA_HOME in eclipse navigate to windows menu -> preferences -> Add runtime variables

OR

Navigate to Run menu -> External Tools configurations -> Navigate to environment tab -> Add JAVA_HOME variable and it's path as it's value to set environment variable in eclipse.

actually the path/classpath/any setting is on "Administrator" privilege and will NOT be accessed if eclipse is started directly. right click on eclipse.exe and select "Run As Administrator".
hope it works

This seems a bug in Eclipse to me.

Eclipse comes with Java built in already. It's somewhere deep down in Eclipse. Users have no idea where it is. Only Eclipse itself can set JAVA_HOME properly.

Installing your own Java and setting JAVA_HOME to point to there seems a bad idea, introducing potential conflicts between the built-in java version and JAVA_HOME contents

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