How to fix jvm options exports javafx 11 to com.jfoenix on gradle idea?

柔情痞子 提交于 2020-01-03 03:13:08

问题


It's been 3 days that I look on the internet how to fix this on gradle

Caused by: java.lang.IllegalAccessError: class com.jfoenix.skins.JFXTabPaneSkin (in module com.jfoenix) cannot access class com.sun.javafx.scene.control.behavior.TabPaneBehavior (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control.behavior to module com.jfoenix

On simple idea projects I was adding

--add-exports javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix --add-exports javafx.controls/com.sun.javafx.scene.control=com.jfoenix --add-exports javafx.base/com.sun.javafx.binding=com.jfoenix --add-exports javafx.graphics/com.sun.javafx.stage=com.jfoenix --add-exports javafx.base/com.sun.javafx.event=com.jfoenix 

I know, I have to add jvm options but how do I ?

I'm using gradle javafx 11.0.2, java 11, on intellij idea,

this is the build.gradle

plugins {
    id 'java'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.8'
}

compileJava.options.encoding = 'UTF-8'
repositories {
    mavenCentral()
}

dependencies {
    //     https://mvnrepository.com/artifact/com.jfoenix/jfoenix
    compile group: 'com.jfoenix', name: 'jfoenix', version: '9.0.9'
    compile group: 'de.jensd', name: 'fontawesomefx-fontawesome', version: '4.7.0-9.1.2'
    // https://mvnrepository.com/artifact/de.jensd/fontawesomefx-commons
    runtime group: 'de.jensd', name: 'fontawesomefx-commons', version: '9.1.2'
// https://mvnrepository.com/artifact/com.h2database/h2
    compile group: 'com.h2database', name: 'h2', version: '1.4.199'
}

javafx {
    version = "11.0.2"
    modules = [ 'javafx.controls', 'javafx.fxml','javafx.graphics','javafx.base' ]
}

mainClassName = 'org.yanisboukir.agence.Main'

Thanks


回答1:


If you are running a non modular project (you don't have module-info.java), to include the VM arguments in your run task, all you need to add to your build.gradle file is:

run {

    jvmArgs = [

        "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED",

        "--add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED",

        "--add-exports=javafx.base/com.sun.javafx.binding=ALL-UNNAMED",
        "--add-exports=javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED",
        "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED"
    ]

}

Note that in this case, you can't use --add-exports=...=com.jfoenix.

If you run a modular project, with a module descriptor like:

module hellofx {
    
    requires javafx.controls;
    
    requires javafx.fxml;
    
    requires com.jfoenix;

    
    opens org.openjfx to javafx.fxml;
    
    exports org.openjfx;

}

now these are the VM arguments that you will have to include in your build file:

run {

    jvmArgs = [

        "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix",

        "--add-exports=javafx.controls/com.sun.javafx.scene.control=com.jfoenix",

        "--add-exports=javafx.base/com.sun.javafx.binding=com.jfoenix",
        "--add-exports=javafx.graphics/com.sun.javafx.stage=com.jfoenix",
        "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix"
    ]

}


来源:https://stackoverflow.com/questions/58133725/how-to-fix-jvm-options-exports-javafx-11-to-com-jfoenix-on-gradle-idea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!