Eclipse:JAVA_HOME 未设置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39827802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 21:28:52  来源:igfitidea点击:

Eclipse: JAVA_HOME not set

javaeclipseenvironment-variables

提问by En-Motion

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:

当我尝试在 Eclipse 中运行 Web 服务器时出现以下错误:

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

该系统找不到指定的路径。JAVA HOME 设置不正确。

But checking my env variables they look correct:

但是检查我的 env 变量,它们看起来是正确的:

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?

还有什么我想念的吗?

采纳答案by himeshc_IB

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

检查系统环境变量和用户环境变量......似乎eclipse正在从不同的环境中获取变量..

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.

如果问题仍然存在,则在 eclipse 中设置 JAVA_HOME 以明确告诉 eclipse java 在系统中的安装位置。要在 eclispe 中设置 JAVA_HOME,下面给出了几个选项。

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

要在 Eclipse 中设置 JAVA_HOME,请导航到 Windows 菜单 -> 首选项 -> 添加运行时变量

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.

导航到运行菜单 -> 外部工具配置 -> 导航到环境选项卡 -> 添加 JAVA_HOME 变量及其路径作为在 eclipse 中设置环境变量的值。

回答by Alkaram Ansari

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

实际上,路径/类路径/任何设置都具有“管理员”权限,如果直接启动 eclipse,则不会被访问。右键单击 eclipse.exe 并选择“以管理员身份运行”。
希望它有效