java 也许JAVA_HOME没有指向JDK

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

Perhaps JAVA_HOME does not point to the JDK

javacordova

提问by Chepaki

i am getting this error during making phonegap build

我在制作 phonegap 时遇到这个错误

C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:601: The followin
g error occurred while executing this line:
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:720: The followin
g error occurred while executing this line:
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:734: Unable to fi
nd a javac compiler;
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\jre1.8.0_25"

Total time: 45 seconds



D:\xampp\htdocs\mymind\mymind\mymind\platforms\android\cordova\node_modules\q\q.
js:126
                    throw e;
                          ^
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,D:\xampp\htdocs\mymi
nd\mymind\mymind\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.
dir=ant-gen

i think problem with the PATH which i have added to the system variables of the windows envirement variables.

我认为我添加到 Windows 环境变量的系统变量中的 PATH 有问题。

  • JAVA_HOME -> C:\Program Files\Java\jdk1.8.0_25;C:\Progra~2\Java\jdk1.8.0_25\jre
  • JAVA_HOME -> C:\Program Files\Java\jdk1.8.0_25;C:\Progra~2\Java\jdk1.8.0_25\jre

another error

另一个错误

BUILD FAILED
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:653: The followin
g error occurred while executing this line:
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:698: null returne
d: 1

Total time: 14 seconds


D:\xampp\htdocs\mymind\mymind\mymind\platforms\android\cordova\node_modules\q\q.
js:126
                    throw e;
                          ^
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,D:\xampp\htdocs\mymi
nd\mymind\mymind\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.
dir=ant-gen

Error: D:\xampp\htdocs\mymind\mymind\mymind\platforms\android\cordova\build.bat:
 Command failed with exit code 8
    at ChildProcess.whenDone (C:\Users\umar.farooq\AppData\Roaming\npm\node_modu
les\phonegap\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspaw
n.js:135:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Process.ChildProcess._handle.onexit (child_process.js:823:5)

回答by Predrag Maric

It is currently set to "C:\Program Files\Java\jre1.8.0_25"

当前设置为“C:\Program Files\Java\jre1.8.0_25”

jrestands for Java Runtime Environment, and you need jdkwhich is Java Development Kit.

jre代表Java Runtime Environment,你需要jdk它是Java Development Kit。

So, JAVA_HOMEshould point to C:\Program Files\Java\jdk1.8.0_25, and in your PATHsystem variable you should have C:\Program Files\Java\jdk1.8.0_25\bin.

所以,JAVA_HOME应该指向C:\Program Files\Java\jdk1.8.0_25,并且在你的PATH系统变量中你应该有C:\Program Files\Java\jdk1.8.0_25\bin.

回答by Chepaki

Make sure you're using the Java SE SDK and not the Java EE SDK, because android wouldn't recognize the second.

确保您使用的是 Java SE SDK 而不是 Java EE SDK,因为 android 不会识别第二个。