0

basis:

Followed the https://openjfx.io/ page to learn JavaFX. The code works on another computer. I uploaded on a repo using git. Downloaded to another computer. Old computer was running Java 10. JDK 10. Which has JavaFX built in (also a reason why I initially chose it). Thought I should keep up with latest trends (or unraveling mess as I see it when it comes to Java). So I downloaded OpenJDK 13 on another computer. Downloaded OpenFX 13 on it as well, as per the above mentioned page. I did get the Error they warn might show up:

Error: JavaFX runtime components are missing, and are required to run this application

So I followed along with the "solution". Now when I press run, not only do I get a weird dialog box that looks like this:

enter image description here

But when I chose "ThaApp" I get another Exception of which I cannot make any sense:

    Exception in Application start method
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
    at java.base/java.lang.Thread.run(Thread.java:830)
Caused by: java.lang.IllegalAccessError: class com.sun.media.jfxmediaimpl.NativeMediaManager (in unnamed module @0x35c1057f) cannot access class com.sun.glass.utils.NativeLibLoader (in module javafx.graphics) because module javafx.graphics does not export com.sun.glass.utils to unnamed module @0x35c1057f
    at com.sun.media.jfxmediaimpl.NativeMediaManager.lambda$new$0(NativeMediaManager.java:110)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
    at com.sun.media.jfxmediaimpl.NativeMediaManager.<init>(NativeMediaManager.java:107)
    at com.sun.media.jfxmediaimpl.NativeMediaManager$NativeMediaManagerInitializer.<clinit>(NativeMediaManager.java:78)
    at com.sun.media.jfxmediaimpl.NativeMediaManager.getDefaultInstance(NativeMediaManager.java:90)
    at com.sun.media.jfxmedia.MediaManager.canPlayProtocol(MediaManager.java:78)
    at com.sun.media.jfxmedia.locator.Locator.<init>(Locator.java:239)
    at javafx.scene.media.Media.<init>(Media.java:393)
    at mypack.ThaApp.start(ThaApp.java:32)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    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(AccessController.java:391)
    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)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    ... 1 more
Exception running application mypack.ThaApp

Granted, the code uploaded to the repo ran on Java 10 and had a bunch of eclipse configs. But I did change it to Java 13 on eclipse after pulling the code to the other computer. In "run configurations" as well as in "BuildPath". I also, in "Build Path", tried to add the JavaFX jars "manually", so insted of adding a "library" as in the solution of the above mentioned page, I did not have a library but rather loose jars, but that also did not help.

Here is a picture I belive should show all the libraries needed:

enter image description here

Are there any things people got stuck in when following this guide? Are there some things people tend to forget when they try to get JavaFX working in general? Mostly when using OpenJDK and having to add libraries or other stuff? Or does anyone understand the Stacktrace? Or even that weird dialog box?

But the main question. How to make the code work? Any thoughts are welcome!

brat
  • 586
  • 5
  • 17

1 Answers1

0

As often happens. Once I put my problems in words, something clicks. Eventually found a solution, thanks to this answer

https://stackoverflow.com/a/53237667/7989121

Aparently one needs to add javax.media to this line in Run configurations, like so:

--module-path /path/to/javafx-sdk-13/lib --add-modules javafx.controls,javafx.fxml,javax.media

Was about to delete the question, but though someone might benefit if they have same problem and find this page. If the high lords of Stackoverflow deem it unecessary, or someone with rights to delete, then by all means do :) Since its just run configurations I bet It will be problems once I want to make it into a runnable jar. So... will be back with more questions ;) Peace out!

brat
  • 586
  • 5
  • 17
  • 1
    And sorry for answering my own questions so often :-/. But it doesnt seem to click until I actually press that magic Post button x) – brat Mar 05 '20 at 15:07