Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
856 views
in Technique[技术] by (71.8m points)

javafx - Task 'run' causes: org.joor.ReflectException: java.lang.NoSuchFieldException: javaExecHandleBuilder - Gluon Mobile Project

When I try to run my entire project in NetBeans I get the following error log:

...
Task :run FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> org.joor.ReflectException: java.lang.NoSuchFieldException: javaExecHandleBuilder

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s

I don't know what's going on, I specified the main class in build.gradle... Pls, help!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I found a solution to develop JavaFX project with Gradle version 6.6 or newer. You need to remove the javafx-gradle-plugin and use the JPMS support from Gradle itself. With removing the javafx-gradle-plugin, you need to maintain the JavaFX dependencies by yourself. Here an example of the build.gradle setup.

plugins {
    id 'application'
}

def currentOS = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem;
def platform
if (currentOS.isWindows()) {
     platform = 'win'
} else if (currentOS.isLinux()) {
     platform = 'linux'
} else if (currentOS.isMacOsX()) {
     platform = 'mac'
}

java {
    modularity.inferModulePath = true
}

dependencies {
    implementation "org.openjfx:javafx-base:15.0.1:${platform}"
    implementation "org.openjfx:javafx-controls:15.0.1:${platform}"
    implementation "org.openjfx:javafx-graphics:15.0.1:${platform}"
    implementation "org.openjfx:javafx-fxml:15.0.1:${platform}"
}

application {
    mainModule = 'com.your.module'
    mainClass = 'com.your.package.Main'
}

On your module-info.java file you need to declare the require JavaFX module.

module com.your.module {

    requires javafx.base;
    requires javafx.controls;
    requires javafx.graphics;
    requires javafx.fxml;

    opens com.your.package to javafx.fxml;

    exports com.your.package;

}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...