无法运行“ javac -version”,请确保您已安装JDK版本8

时间:2019-05-06 05:03:25

标签: cordova ionic-framework cmd java-8 javac

我是离子发展的新手。 对于开发,我已经安装了离子开发所需的要求。我正在创建离子版本1应用程序。

我的问题是,我安装了jdk1.8.0_212并在系统变量中设置了路径。

JAVA_HOME : C:\Program Files\Java\jdk1.8.0_212

并在路径

%JAVA_HOME%\bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;C:\gradle-5.4-all\gradle-5.4\bin

然后我运行命令

ionic cordova run android

我得到这个:

Failed to run "javac -version", make sure that you have a JDK version 8 
installed.
You can get it from the following location:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads- 
2133151.html

Your JAVA_HOME is invalid: C:\Program Files\Java\jdk-12.0.1
[ERROR] An error occurred while running subprocess cordova.

    cordova run android exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.

当我运行javac时,我得到了这个信息:

'javac' is not recognized as an internal or external command,
 operable program or batch file.

请帮助我解决这个问题,这3天让我感到痛苦。

请找到离子信息

ionic info

Ionic:

ionic (Ionic CLI) : 4.12.0 
(C:\Users\sreek\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework   : ionic1 1.3.4
@ionic/v1-toolkit : 1.0.22

Cordova:

cordova (Cordova CLI) : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms     : android 8.0.0
Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova- 
plugin-ionic-webview 4.0.1, (and 4 other plugins)

System:

Android SDK Tools : 26.1.1 (C:\Users\sreek\AppData\Local\Android\Sdk)
NodeJS            : v10.15.3 (C:\Program Files\nodejs\node.exe)
npm               : 6.4.1
OS                : Windows 10

1 个答案:

答案 0 :(得分:0)

在以下位置查看答案: Ionic Build Failed: JAVA_HOME is invalid

您还需要在path变量中明确提及带有bin的java home完整路径。另外,请确保重新启动控制台以反映更改。