9

I have just installed SDK 11 and using Javafx from maven. My pom is as follows.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.restfbui21feb</groupId>
    <artifactId>uipostdownload</artifactId>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>

            <plugin>
                <groupId>com.zenjava</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>LATEST</version>
                <configuration>
                    <mainClass>ui.postDisplayAndAction</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.restfb</groupId>
            <artifactId>restfb</artifactId>
            <version>2.16.0</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.8.3</version>
        </dependency>

    </dependencies>

</project>

I am using WebView which helps me in seeing facebook data and downloading whatever i require.

Please find the exception as follows:

java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.sg.prism.web.NGWebView (in unnamed module @0x253d5cf1) cannot access class com.sun.javafx.sg.prism.NGGroup (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.sg.prism to unnamed module @0x253d5cf1
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at ui.PostDisplayandAction.<clinit>(PostDisplayandAction.java:37)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:398)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.loadClass(LauncherImpl.java:382)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplicationWithArgs$3(LauncherImpl.java:421)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)

I have added the following VM --module-path /Applications/javafx-sdk-11.0.2/lib --add-modules=javafx.controls,javafx.fxml,javafx.base

It seems that I am trying from past 2 hours for this code to work. There are no compile errors in the code. What mistakes am I making?

Abhijeet
  • 689
  • 2
  • 10
  • 19
  • 3
    How do you compile your project, `mvn compile`? Or using `javac`? Make sure you are using JDK11. How do you run it? Via maven or java command? With the latter, you will need `--add-modules=javafx.web` if you use a WebView. – José Pereda Feb 22 '19 at 10:11
  • I am using Intellij to run it. I have returned to Java Swing anyway – Abhijeet Feb 22 '19 at 11:10

6 Answers6

14

Maybe you can check this issue https://github.com/GSI-CS-CO/chart-fx/issues/6
It helped me solve this problem
Simply attach this content to your configurations

--module-path /path/to/javafx-sdk-11.0.2/lib --add-modules=javafx.swing,javafx.graphics,javafx.fxml,javafx.media,javafx.web --add-reads javafx.graphics=ALL-UNNAMED --add-opens javafx.controls/com.sun.javafx.charts=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.iio=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.iio.common=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.css=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.runtime=ALL-UNNAMED

Maybe it works

Hugh
  • 156
  • 1
  • 5
  • in my case -- 1. module-path is required. 2. module list is required (esp javafx.web) 3. export list is required --module-path /Applications/javafx-sdk-15.0.1/lib --add-modules=javafx.controls,javafx.fxml,javafx.base --add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED – ChingKun Yu Dec 14 '20 at 06:50
  • Alhamdulillah Worked for me – Noor Hossain Jun 29 '21 at 17:35
4

I just add to my VM Options this line and it works

--add-modules javafx.web
1

You have to add --add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED and it should work !

pacataque
  • 130
  • 12
1

I had the same problem when I added a WebView. What worked for me is the following:

1- turn your project into a modular one by going to File/New/Module From Existing Sources ..

2- add the line "requires javafx.web" into your module-info.java file, like the following:

module com.example.demo {
    requires javafx.controls;
    requires javafx.fxml;
    requires javafx.web;

    opens com.example.demo to javafx.fxml;
    exports com.example.demo;
}

3- add the following dependencies to your pom.xml file:

        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>11.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>11.0.2</version>
        </dependency>

        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-web</artifactId>
            <version>11.0.2</version>
        </dependency>

3- Finally, I changed my openJdk to Amazon Corretto JDK. Consider also the version of Azul Zulu Jdk that includes JavaFX out of the box (you don't even need to include JavaFx dependencies in your project pom)

Nadirspam
  • 161
  • 7
1

I got mine fixed by going in Run Configuration -> VM arguments and adding the following argument lines:

--add-modules=javafx.swing,javafx.graphics,javafx.fxml,javafx.media,javafx.web
--add-reads javafx.graphics=ALL-UNNAMED
--add-opens javafx.controls/com.sun.javafx.charts=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.javafx.iio=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.javafx.iio.common=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.javafx.css=ALL-UNNAMED
--add-opens javafx.base/com.sun.javafx.runtime=ALL-UNNAMED
rofeo
  • 41
  • 2
0

In my case the problem arose just after going from jdk13 to jdk14. So you better add this to your VM on your editor:

--module-path /Applications/javafx-sdk-11.0.2/lib --add-modules=javafx.controls,javafx.fxml,javafx.base --add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED

Or just complete what was there with --add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED

M E S A B O
  • 783
  • 1
  • 11
  • 15