Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javafx.controls could not be found JavaFX 11 / JDK 11.0.1 [duplicate]

I am using InteliJ, I've gone through all other solutions that seem to work for everybody else. I was getting an error:

Caused by: java.lang.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0x5782d366) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module @0x5782d366

I then added the following to VM options in the run config:

--module-path="C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib" \ 
    --add-modules=javafx.controls \
    --add-exports=javafx.graphics/com.sun.javafx.util=ALL-UNNAMED \
    --add-exports=javafx.base/com.sun.javafx.reflect=ALL-UNNAMED \
    --add-exports=javafx.base/com.sun.javafx.beans=ALL-UNNAMED \
    --add-exports=javafx.graphics/com.sun.glass.utils=ALL-UNNAMED \
    --add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED

That seemed to partially fix the problem? Howerver when I try to run this I don't get a whole stack trace of errors, I get these three lines:

"C:\Program Files\Java\jdk-11.0.1\bin\java.exe" \
    --module-path=C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib \
    --add-modules=javafx.controls,javafx.fxml \
    --add-exports=javafx.graphics/com.sun.javafx.util=ALL-UNNAMED \
    --add-exports=javafx.base/com.sun.javafx.reflect=ALL-UNNAMED \
    --add-exports=javafx.base/com.sun.javafx.beans=ALL-UNNAMED \
    --add-exports=javafx.graphics/com.sun.glass.utils=ALL-UNNAMED \
    --add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED \
    --add-modules javafx.base,javafx.graphics \
    --add-reads javafx.base=ALL-UNNAMED \
    --add-reads javafx.graphics=ALL-UNNAMED \
    "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.3\lib\idea_rt.jar=60572:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.3\bin" \
    -Dfile.encoding=UTF-8 \
    -classpath C:\Users\mresp_000\Desktop\Business\Code\VirtualBeats\out\production\VirtualBeats;\
        C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib\src.zip;\
        C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib\javafx-swt.jar;\
        C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib\javafx.web.jar;\
        C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib\javafx.base.jar;\
        C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib\javafx.fxml.jar;\
        C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib\javafx.media.jar;\
        C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib\javafx.swing.jar;\
        C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib\javafx.controls.jar;\
        C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib\javafx.graphics.jar \
    -p C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib\javafx.base.jar;\
        C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib\javafx.graphics.jar \
    virtualbeats.Main
Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.controls not found

Process finished with exit code 1

I get the same error when I only put in the following to the VM options:

--module-path="C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib"
--add-modules=javafx.controls,javafx.fxml

Here is a picture of my run options (I have ticked and un-ticked the "include dependencies withg provided scope" box, neither work.

The library is pointing to the right place and I've tried rebuilding the project, nothing is working. When I go to my command line and type:

dir "C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib"

I get the following output: output of cmd

So everything is infact there and pointing to the exact location it needs to be pointing to. Adding the .jar extension to the add-module also does nothing.

like image 252
MahBoi Avatar asked Dec 04 '18 16:12

MahBoi


People also ask

How do I fix JavaFX control not found?

To Solve error: module not found: javafx. controls Error You just need to add PATH_TO_FX. First of all Use %PATH_TO_FX% instead of $PATH_TO_FX in the command line. Then Recreate the variables for both system and user PATH_TO_FX enclosing its value in quotation marks.

Does JavaFX work with Java 11?

For JDK 11 and later releases, Oracle has open sourced JavaFX. You can find more information at OpenJFX project.

Does OpenJDK 11 support JavaFX?

JavaFX crashes with OpenJDK 11 on Ubuntu 18.04 with Wayland The recommended workaround is to use the Xorg server instead of the Wayland server when running JavaFX applications. Note that Wayland is not supported by JDK 10 or JDK 11.


1 Answers

Try:

--module-path C:\Users\mresp_000\Desktop\Business\Code\SDKS\javafx-sdk-11.0.1\lib --add-modules=ALL-MODULE-PATH

as Runconfiguration, I don't know, maybe it works?

like image 151
Chris999Tian Avatar answered Oct 14 '22 02:10

Chris999Tian