1

JDK Version - jdk-13.0.2 : environmental variable added as well as path variable

JFX Version - javafx-sdk-13.0.2 : environmental variable added as well as path variable

Eclipse Version - 2019-12-R : e(fx)clipse plugin installed : scene builder

OS - Windows 10


Now inside eclipse I have configured some things to allow JavaFX to run inside the IDE. So I will list what I have done inside the IDE configurations:

Window > Preferences > Java > Installed JRE's > Added jdk-13.0.2 under "Standard VM" option > VM Argument --module-path "C:\Program Files\Java\javafx-sdk-13.0.2\lib" --add-modules javafx.controls,javafx.fxml .

Window > Preferences > Java > Build Path > User Libraries > Created a new library containing javafx.base, javafx.controls, javafx.fxml, javafx.graphics, javafx.media, javafx.swing, javafx.web, javafx-swt .jar files.

For the individual projects I still have to add the new user library to the "class-path" so to do so I: Right-click Project folder > Properties > Java Build Path > Libraries > Delete the default JavaFX SDK folder (doesn't contain .jar files) > Add New Library > User Library > Select my created JavaFX library that contains the .jars. At this point I can debug, and run anything Javafx inside the IDE.


Both test cases are just the basic build of 300x300 box with no other components in them (ruined an entire project before hand trying to figure this out). The difference between them is only 1 contains a module-info.java (created a module when project was created). The module-info.java contains:

module testing {
    exports application;
    requires javafx.graphics;
    requires javafx.base;
    requires javafx.controls;
    requires javafx.fxml;
    requires javafx.media;
    requires javafx.swing;
    requires javafx.swt;
    requires javafx.web;
}

The other "Testing2" does not have a module-info.java and one was not created when the project was (unchecked box). When I try to "export" either of them using Runnable Jar option then "extract required libraries into generated jar" it exports with the following error : duplicate entry: module-info.class . Which is confusing because the "Testing2" shouldn't have any module? If I export using the "Package required libraries into generated jar" I get no error upon export for either, but the .jar file itself when clicked opens the cmd box for about 0.5 seconds, closes and does nothing else. Same if I use a separate folder for libraries when exporting. Trying to open from the command line I get "Unable to access Jarfile \path\jar.jar", and then if I open cmd as admin I get "Missing Javafx Runtime components" && I have gotten

`Graphics Device initialization failed for :  d3d, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
        at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280)
        at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:244)
        at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:260)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
        at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
        at 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.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
        at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:94)
        at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
        ... 1 more
Exception in thread "main" 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 org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.RuntimeException: No toolkit found
        at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
        at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)`enter code here`
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        at java.base/java.lang.Thread.run(Thread.java:830)

Now the only thing I have not been able to completely test out in some of the answers I have found is the "manifest". So far I have been under the impression that eclipse automatically creates one and when I choose the launch configuration at time of exporting I am choosing the entry point with my main class. I also have not been able to access one, and when I searched for how to create one in eclipse literally everyones answers are "eclipse does it for you automatically" or are using a 5+ year old version that I has screen steps that I simply do not have in the newest version of the IDE. If anyone could give me some insight on what might actually be going wrong here I would appreciate it very much. Thank you!

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
RobertB922
  • 189
  • 2
  • 9
  • 1
    _the "Testing2" shouldn't have any module_ Not true. It is in the [unnamed module](https://www.logicbig.com/tutorials/core-java-tutorial/modules/unnamed-modules.html) – Abra Feb 03 '20 at 02:44
  • 1
    _duplicate entry: module-info.class_ means two (or more) JARs contain the same class - because all your classes are in the _unnamed module_ (see my previous comment) – Abra Feb 03 '20 at 02:49
  • Perhaps [this SO question](https://stackoverflow.com/questions/21185156/javafx-on-linux-is-showing-a-graphics-device-initialization-failed-for-es2-s) will help with your `Graphics Device initialization failed` – Abra Feb 03 '20 at 02:52
  • @Abra, The last reference you posted is a little outdated. It's dealing with 1.8.0 and Linux from about 4 years ago. Though I do appreciate the reference and will try, I wish my original post wasn't edited so you everyone would of known what I have already tried but Hovercraft Full of Eels apparently doesn't think relevant information pertains to the problem. – RobertB922 Feb 03 '20 at 04:35
  • @Abra, thank you for the reference to the _unnamed module_. I actually managed to clear the error for **duplicate entry: module-info.java** with your help on that one. I didn't notice as I was creating new projects as **JavaFX** project that the **jre system library** was already trying to use the javafx.controls jar. By removing that I was able to get that error to clear when exporting as **Extract required libraries into generated jar**. Though its still not running when clicked or accessed through cmd, that's atleast one step in the right direction. – RobertB922 Feb 03 '20 at 04:45

2 Answers2

3

Alright I have figured it out (at least for me). I hope this helps anyone in the future. So I went into command prompt and changed my directory to where the .jar file was located by

cd path\to\file.jar

For ease I saved to desktop so it looked like cd desktop

Next I set the path to JavaFx by

set PATH_TO_FX="path\to\JavaFX\lib"

In my case it looked like set PATH_TO_FX="C:\Program Files\Java\javafx-sdk-13.0.2\lib" This is an important step, if you don't set the path the .jar file will not open!

Then I added the VM arguments that are needed in Eclipse to get javaFX to run (at least with jdk13 and jfx13) which looked like this

java -jar --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.fxml Testing.jar

Apparently, I and many others keep forgetting that the VM arguments do not export with the .jar file. The only things you should need to modify with the above command lines are the paths to your jfx\lib folder, and the name of .jar file. I showed how mine looked so if someone gets confused working in the command prompt they have a reference point. However, this still doesn't allow it to work by double clicking the .jar file. I am working on a solution for that and I edit this to reflect that method as well.

RobertB922
  • 189
  • 2
  • 9
  • Hi there, thanks for the command line explanation. Did you ever get a solution working for double clicking the .jar file? Thanks. – O. Matthews Jun 12 '21 at 23:52
0

Simply you can create .bat file in the dist folder to execute the .jar file by specifying the JavaFx module path.

To create .bat file you can insert following code into the text file (be sure to update the "path\to\JavaFX\lib" to your JavaFx lib folder path and "YourApplicationName.jar" to your application name)

java -jar --module-path "path\to\JavaFX\lib" --add-modules javafx.controls,javafx.fxml "YourApplicationName.jar"

Save this text file as: yourFileName.bat

Now you can execute your .jar file by double clicking the yourFileName.bat file

It's recommended to have copy of .bat file because when you rebuild the project, the original .bat file will be destroyed.

flyingfishcattle
  • 1,817
  • 3
  • 14
  • 25