windows JAVA_HOME 变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7438160/
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-09-09 08:46:17  来源:igfitidea点击:

JAVA_HOME variable

windowsantjava-home

提问by Sapphire

I set my JAVA_HOME variable to point to the jdk and I added %JAVA_HOME%\bin to the Path variable. However, my ant script is not able to find the jdk. It's looking into the wrong folder for Java compiler. here's the error I'm getting.

我将 JAVA_HOME 变量设置为指向 jdk,并将 %JAVA_HOME%\bin 添加到 Path 变量中。但是,我的 ant 脚本无法找到 jdk。它正在查看 Java 编译器的错误文件夹。这是我得到的错误。

com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to C:\Program Files\Java\jre6

com.sun.tools.javac.Main 不在类路径上。也许 JAVA_HOME 没有指向 JDK。目前设置为C:\Program Files\Java\jre6

I set my JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0

我设置了我的 JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0

What am I doing wrong? Please help!

我究竟做错了什么?请帮忙!

回答by mihk3l

If your Java installation directory has a space in its path name, you should use the shortened path name (e.g. C:\Progra~1\Java\jre6) in the environment variable instead.

如果您的 Java 安装目录的路径名中有空格,您应该在环境变量中使用缩短的路径名(例如 C:\Progra~1\Java\jre6)。

  • Progra~1 = 'Program Files'
  • Progra~2 = 'Program Files(x86)'
  • 程序~1 = '程序文件'
  • 程序~2 = '程序文件(x86)'

Setting the JAVA_HOME Variable in Windows

在 Windows 中设置 JAVA_HOME 变量

回答by Jason Dean

Try setting it to

尝试将其设置为

JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0\jre

回答by Csaba Tenkes

When you want to use JAVA_HOME in your path variable it is recommended to use "%JAVA_HOME%\bin"instead of %JAVA_HOME%\bin.

当你想在你的路径变量使用JAVA_HOME建议使用"%JAVA_HOME%\bin"来代替%JAVA_HOME%\bin