科尔多瓦运行错误的Java版本。(Cordova is running the wrong Java version. How do I get Cordova to run a specific Java version?) [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release

error: strings in switch are not supported in -source 1.5 [javac] switch (xmlData[i][1]) { [javac] ^ [javac] (use -source 7 or higher to enable strings in switch)

我在编译与Cordova for Android的APK时运行Java 1.5时出现警告和错误。 我不能在switch语句中使用字符串。 (编译过程错误)

我的系统是64位Windows 7.我的科尔多瓦版本是3.5。 我正在使用git-scm。 ( http://git-scm.com/ )

我正在运行这个命令: cordova run android --release 。 我的Java环境变量列出了C:\Program Files\Java\jdk1.8.0_20作为Java目录。 我的路径环境变量将Java路径设置为列表中的第一项。 除了我刚刚从Oracle网站重新安装的以外,每个Java修补程序和版本都已卸载。 我重新启动了我的电脑。 java -version给我java version "1.8.0_20" 。 javac -version给我javac 1.8.0_20 。 我的所有目标都是=android-19 , =debug或=release 。 android:minSdkVersion总是设置为“14”,无处不在。 android:targetSdkVersion始终设置为“19”,无处不在。

我该如何强制Cordova运行Java 8?

[javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release

and

error: strings in switch are not supported in -source 1.5 [javac] switch (xmlData[i][1]) { [javac] ^ [javac] (use -source 7 or higher to enable strings in switch)

I am getting warnings and errors that I am running Java 1.5 when compiling an APK with Cordova for Android. I can't use strings in switch statements. (the compilation process errors)

My system is 64-bit Windows 7. My Cordova version is 3.5. I am using git-scm. (http://git-scm.com/)

I am running this command: cordova run android --release. My Java environment variable lists C:\Program Files\Java\jdk1.8.0_20 as the Java directory. My path enviroment variable sets the Java path as the first item in the list. Every Java patch and version is uninstalled except what I just re-installed from Oracle's site. I restarted my computer. java -version gives me java version "1.8.0_20". javac -version gives me javac 1.8.0_20. All my targets are =android-19, =debug, or =release. android:minSdkVersion is always set to "14", everywhere. android:targetSdkVersion is always set to "19", everywhere.

How can I force Cordova to run Java 8?

最满意答案

要修复命令行构建,请将这些行添加到您的ant build.xml属性文件中(例如,如果使用Android SDK,它位于${sdk.dir}/tools/ant/build.xml ):

<property name="java.target" value="1.7" />
<property name="java.source" value="1.7" />

To fix for command line builds, add these lines (or set appropriate values if already present) to your ant build.xml property file (for example if using Android SDK, it's in ${sdk.dir}/tools/ant/build.xml):

<property name="java.target" value="1.7" />
<property name="java.source" value="1.7" />科尔多瓦运行错误的Java版本。(Cordova is running the wrong Java version. How do I get Cordova to run a specific Java version?)

                [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
 

error: strings in switch are not supported in -source 1.5 [javac] switch (xmlData[i][1]) { [javac] ^ [javac] (use -source 7 or higher to enable strings in switch)

我在编译与Cordova for Android的APK时运行Java 1.5时出现警告和错误。 我不能在switch语句中使用字符串。 (编译过程错误)

我的系统是64位Windows 7.我的科尔多瓦版本是3.5。 我正在使用git-scm。 ( http://git-scm.com/ )

我正在运行这个命令: cordova run android --release 。 我的Java环境变量列出了C:\Program Files\Java\jdk1.8.0_20作为Java目录。 我的路径环境变量将Java路径设置为列表中的第一项。 除了我刚刚从Oracle网站重新安装的以外,每个Java修补程序和版本都已卸载。 我重新启动了我的电脑。 java -version给我java version "1.8.0_20" 。 javac -version给我javac 1.8.0_20 。 我的所有目标都是=android-19 , =debug或=release 。 android:minSdkVersion总是设置为“14”,无处不在。 android:targetSdkVersion始终设置为“19”,无处不在。

我该如何强制Cordova运行Java 8?

[javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release

and

error: strings in switch are not supported in -source 1.5 [javac] switch (xmlData[i][1]) { [javac] ^ [javac] (use -source 7 or higher to enable strings in switch)

I am getting warnings and errors that I am running Java 1.5 when compiling an APK with Cordova for Android. I can't use strings in switch statements. (the compilation process errors)

My system is 64-bit Windows 7. My Cordova version is 3.5. I am using git-scm. (http://git-scm.com/)

I am running this command: cordova run android --release. My Java environment variable lists C:\Program Files\Java\jdk1.8.0_20 as the Java directory. My path enviroment variable sets the Java path as the first item in the list. Every Java patch and version is uninstalled except what I just re-installed from Oracle's site. I restarted my computer. java -version gives me java version "1.8.0_20". javac -version gives me javac 1.8.0_20. All my targets are =android-19, =debug, or =release. android:minSdkVersion is always set to "14", everywhere. android:targetSdkVersion is always set to "19", everywhere.

How can I force Cordova to run Java 8?

最满意答案

要修复命令行构建,请将这些行添加到您的ant build.xml属性文件中(例如,如果使用Android SDK,它位于${sdk.dir}/tools/ant/build.xml ):

<property name="java.target" value="1.7" />
<property name="java.source" value="1.7" />

To fix for command line builds, add these lines (or set appropriate values if already present) to your ant build.xml property file (for example if using Android SDK, it's in ${sdk.dir}/tools/ant/build.xml):

<property name="java.target" value="1.7" />
<property name="java.source" value="1.7" />