我已尝试将grade.properties
文件夹中.gradle
文件中的jdk设置为:org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/java
但是项目仍然使用jdk 8
我在Mac上使用Eclipse,并且还尝试将Eclipse>偏好设置> Java>已安装的JRE中的jdk 9设置为默认值。
如何更改Gluon项目使用的jdk版本?
这是我的build.gradle:
buildscript {
repositories {
jcenter()
google()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:2.0.28'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.directions.Direction'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
println JavaVersion.current();
if (JavaVersion.current() == JavaVersion.VERSION_1_9) {
compile 'com.gluonhq:charm:5.0.0-jdk9'
androidRuntime 'com.gluonhq:charm:5.0.0'
} else {
compile 'com.gluonhq:charm:5.0.0'
}
compile 'com.fasterxml.jackson.core:jackson-core:2.7.3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
compile 'com.gluonhq:charm:5.0.0'
compile 'com.google.api-client:google-api-client:1.23.0'
}
jfxmobile {
downConfig {
version = '3.8.0'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
plugins 'compass', 'display', 'lifecycle', 'magnetometer', 'position', 'settings', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
androidSdk = '/Users/hemma/Library/Android/sdk'
packagingOptions{
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
我的gradle.properties
看起来像这样:
{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Menlo-Regular;\f2\fnil\fcharset0 Monaco;
}
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red255\green255\blue255;\red255\green0\blue0;
}
{\*\expandedcolortbl;;\csgray\c0;\csgray\c100000;\csgenericrgb\c100000\c0\c0;
}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
\f0\fs24 \cf0 ANDROID_HOME=/Users/
\f1\fs22 \cf2 \cb3 \CocoaLigature0 hemma/Library/Android/sdk\
\pard\pardeftab720\partightenfactor0
\f2 \cf4 \cb1 \CocoaLigature1 org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home
\f1 \cf2 \cb3 \CocoaLigature0 \
}
从终端运行项目的./gradlew run
命令时,构建失败,出现异常Process 'command '/Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
。我将org.gradle.java.home
设置为jdk 9
还是jdk 10
都没有关系。我猜grade.properties
看起来不应该像我的吗?
即使我在Eclipse中的Java构建路径设置中删除了jdk 8,也是如此。将Java 8 jre系统库添加到新创建的gluon vm项目中。
gradle.properties
文件包含以下内容:
{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Menlo-Regular;\f2\fnil\fcharset0 Monaco;
}
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red255\green255\blue255;\red255\green0\blue0;
}
{\*\expandedcolortbl;;\csgray\c0;\csgray\c100000;\csgenericrgb\c100000\c0\c0;
}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
\f0\fs24 \cf0 ANDROID_HOME=/Users/
\f1\fs22 \cf2 \cb3 \CocoaLigature0 hemma/Library/Android/sdk\
\pard\pardeftab720\partightenfactor0
\f2 \cf4 \cb1 \CocoaLigature1 org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home
\f1 \cf2 \cb3 \CocoaLigature0 \
}
Gluon插件的版本为2.6.0.v20180424-0818,用于Eclipse氧气
答案 0 :(得分:0)
org.gradle.java.home
必须指向目录。试试:
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/
答案 1 :(得分:0)
我不得不编辑eclipse.ini文件,该文件指向jdk8指向jdk10 bin文件夹。这使我可以与jdk 10一起运行。但是gluon vm项目崩溃了。这是由于它在build.gradle中编译了com.gluonhq:charm:5.0.0。因此,我必须包括jdk 10检查,以便依赖性如下所示
dependencies {
println JavaVersion.current();
if (JavaVersion.current() == JavaVersion.VERSION_1_9 || JavaVersion.current() == JavaVersion.VERSION_1_10) {
compile 'com.gluonhq:charm:5.0.0-jdk9'
androidRuntime 'com.gluonhq:charm:5.0.0'
} else {
compile 'com.gluonhq:charm:5.0.0'
}
}