问题
I wanted to start my first build with ionic. But the Build fails very soon with the following error:
Running command: E:\Apps\ASV\Node\node.exe E:\Apps\ASV\Code\MyASV\hooks\after_prepare\010_add_platform_class.js E:\Apps\ASV\Code\MyASV
add to body class: platform-android
Error: Failed to run "java -version", make sure that you have a JDK installed.
You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.
Your JAVA_HOME is invalid: C:\Program Files\java\jdk1.8.0_77
I tried several things over the past hour to fix this. I deinstalled all Java related stuff, reinstalled it, set the JAVA_HOME several times to the jdk path, added %JAVA_HOME%\bin to the path-variable, but nothing fixed it. Currently my JAVA_HOME, which i had to create manually, looks like this at the moment:
C:\Program Files\Java\jdk1.8.0_77
Please note that this path is different to the one in the error message. The 'Java' is written in lowercase and in uppercase, I don't know if this is relevant. Also changing this JAVA_HOME variable and then trying a rebuild gives the same error, the changed variable seems to have no effect on the one ionic uses.
How can I fix this? What exactly is going wrong?
回答1:
Okay, i fixed it. The Error
Your JAVA_HOME is invalid: C:\Program Files\java\jdk1.7.0_79
Is quite irritating. The error was that the PATH-variable missed an entry like
C:\Program Files\Java\jdk1.7.0_79\bin
Somehow
%JAVA_HOME%\bin
still causes the error.
回答2:
You will need to edit your enviroment variables of your box to point the JAVA_HOME to the currnent jdk bin/ directory
回答3:
it should be pointing to JDK\bin folder , usually C:\ProgramFiles\Java\jdk*\bin directory.
I recently tried in my new windows PC and gone through same issue.
来源:https://stackoverflow.com/questions/36608561/ionic-build-failed-java-home-is-invalid