I am trying to export a runnable .jar file however I am faced with the following problems:
"VM arguments will not be part of the runnable JAR. Arguments can be passed on the command line when launching the JAR"
I ignored the warning and hit finish to create the runnable .jar file. When I double click it doesn't work.
I ran the following code in my command line:
**java -jar C:\path\file.jar --module-path "C:\pathtofxsdk11\lib" --add-modules javafx.controls,javafx.fxml,javafx.base,javafx.swing, javafx.graphics**
After which, I received the following error:
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:222)
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)
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)
I need help with creating the executable Jar.
The options you provided in the command line are in the wrong order. Anything supplied after the name of the jar file (or the main class, if you are not using the -jar option) will be interpreted as an argument to your Java application (as opposed to an argument to the JVM), and passed to the string array in the
public static void main(String[])
method in the main class.
Thus you should use
java --module-path "C:\pathtofxsdk11\lib" --add-modules javafx.controls,javafx.fxml,javafx.base,javafx.swing,javafx.graphics -jar C:\path\file.jar
Note that this doesn't mean the jar file can be used as an "executable jar" that can simply be run on any system, because the JavaFX runtime is not included in the standard Java runtime from version 11 onwards. Instead, you can use the jpackage tool, which is included in JDK 14, to create a native installer bundle. This bundle will include a Java runtime, which you can configure to include JavaFX.
You should first download and unzip the modular version of JavaFX (the "jmods") from here.
Then your jpackage command looks something like the following:
jpackage --module-path "C:\pathtofxmods" --add-modules javafx.controls,javafx.fxml,javafx.swing --input "C:\path" --main-jar file.jar --type exe --name MyApp --dest "C:\path\to\generated\executable"
where C:\pathtofxmods is the library you unzipped in the previous step: it should include a collection of *.jmod files. This will generate an .exe file in C:\path\to\generated\executable which will install the application on a windows system. You can distribute this - note the end users do not even need a JRE, as this will bundle a JRE with the package.
You can also run jlink independently to create the JRE (with JavaFX) that is bundled with the application. See a full tutorial and the full tool documentation.
Related
Showing "Error initializing QuantumRenderer: no suitable pipeline found" after running JavaFX application. I added required JavaFX jar files to the project and I don't know why this error occured.
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 javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:283)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:254)
at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:264)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:410)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
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:566)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:95)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
at java.base/java.lang.Thread.run(Thread.java:829)
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:566)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: No toolkit found
at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:276)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:410)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
... 5 more
In Eclipse IDE create a java project like always and create a new library in Windows > Preferences and under Java > Build Path > User Libraries click on New...
Name the library and add the .jar's clicking on Add External JARs...
Go to the path where you unziped the javafx package and under lib select all the .jar's. click Open and Apply and Close.
You can start importing javafx code.
If you run the application will get an error
"Error: JavaFX runtime components are missing, and are required to run this application"
To fix this go to Run > Run Configurations.
Create a new Configuration under Java Application
On the right in the Arguments tab look for VM Arguments and add
--module-path "PATH_TO_YOUR_JAVAFX_LIB_FOLDER" --add-modules javafx.controls,javafx.fxml
where PATH_TO_YOUR_JAVAFX_LIB_FOLDER in my case would be "C:\Program Files\Java\jdk-11.0.14\openjfx-18.0.1_windows-x64_bin-sdk\javafx-sdk-18.0.1\lib".
Apply the changes and Run
First problem fix
Now, if you try to Export your project the IDE will show you a warning saying that the VM arguments will not be part of the runnable JAR and if you execute the jar you will face the same error: "Error: JavaFX runtime components are missing, and are required to run this application"
I always check "copy the required libraries into a sub-folder next to the jar" in the export wizard.
To fix the error create a new text file next to your exported .jar and name it with the .bat extension (in windows)
Edit the .bat file and add:
java --module-path "PATH_TO_YOUR_JAVAFX_LIB_FOLDER" --add-modules javafx.controls,javafx.fxml -jar YOUR_PROJECT_NAME.jar
All done, but PATH_TO_YOUR_JAVAFX_LIB_FOLDER is in your machine, so what if you run the .jar in another machine?
java --module-path "YOUR_PROJECT_NAME_lib/" --add-modules javafx.controls,javafx.fxml -jar YOUR_PROJECT_NAME.jar
where YOUR_PROJECT_NAME_lib is in the same directory as the exported .jar
If run now you get the error
"Graphics Device initialization failed for : d3d, sw
Error initializing QuantumRenderer: no suitable pipeline found
...
"
This error happens because it doesn't find the natives(.dll), so,
copy the folder bin under PATH_TO_YOUR_JAVAFX paste it in the same folder of the exported .jar file
This should do the trick. Hope this help you.
I have a Problem with Deploying my JavaFX Project to a .jar or .exe File to easily execute it (and achive the Project Requirements).
I am trying to get it to work as a .jar File because I think thats the easier Way to go but maybe I am wrong so it would be awesome if you could help me solve this Problem.
I already tried using the Artifacts from Intellij but this is not working. I get an Errormessage which says "Error: JavaFX runtime components are missing, and are required to run this application".
Then I tried using another Way which I found on the Internet: https://github.com/openjfx/samples/tree/master/CommandLine/Non-modular/CLI but this is resulting in exactly the same message when trying to package it to a .jar File.
All of the above I tried on my existing Project and on a completely new one with nothing inside except the prewirtten Stuff from Intellij when you create a new JavaFX Project.
My Project exists of nothing like Maven or Gradle, I just have a basic JavaFX Project (JavaFX 15 and Java 15) with one additional Library: org.json:json version 20201115
I hope these Informations are enough for you to understand my Problem and hopefully help me, but if not just ask for what you need and I will do my best to provide it to you.
Thanks for helping :)
Best Regards
Maxi
Edit: Errormessage associated to comment below
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 javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:244)
at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:261)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
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:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1071)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:94)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
at java.base/java.lang.Thread.run(Thread.java:832)
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:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1071)
Caused by: java.lang.RuntimeException: No toolkit found
at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:273)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
... 5 more
this might not concern your particular situation, but maybe it can give you a hint.
Short explanation
I solved the "Error initializing QuantumRenderer: no suitable pipeline found"
by manually including library-files to the fat JAR and adding them to the classpath, which is used for execution, with the assistance of Gradle.
I included:
the required openJFX-JARs from my system's openJFX installation
the accompanying C++ libraries like the renderer libprism_sw.so (*.so on linux, *.dll on Windows)
The hint for the libs came from JavaFX on Linux is showing a "Graphics Device initialization failed for : es2, sw"
"The problem can be in your old JRE version, which doesn't contain all the necessary libraries, such as libprism_es2.so or libglass.so, which should be located in /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64."
...
"Download latest JRE from the official Oracle website and copy lib folder to your current JRE location. That should be enough."
Full explanation
"Error initializing QuantumRenderer" Problem
I had a similar problem with a fat JAR filled with several JFX-example classes from the code for a Java-book. The project uses Gradle for build management and runs the JFX-examples using the fat JAR (build/libs/Java-Profi-all.jar).
The "Error initializing QuantumRenderer" appeared when I tried to execute a simple HelloWorld example for JFX (FirstJavaFxExample) on the command line using bin/java of my current JRE without using Gradle. I almost solved the issue with the hints on JavaFX on Linux is showing a "Graphics Device initialization failed for : es2, sw" , but I got stuck on the same error in the end. Even if I added the required openJFX-JARs and accompanying C++ libraries in the fat JAR and to the classpath via "-cp ...:projectdir/build/requiredLibs".
Used command:
/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/bin/java -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -Dprism.verbose=true -cp projectdir/build/libs/Java-Profi-all.jar:projectdir/build/requiredLibs ch14_javafx.basics.FirstJavaFxExample
Error:
Prism pipeline init order: es2 sw
Using java-based Pisces rasterizer
Using dirty region optimizations
Not using texture mask for primitives
Not forcing power of 2 sizes for textures
Using hardware CLAMP_TO_ZERO mode
Opting in for HiDPI pixel scaling
Prism pipeline name = com.sun.prism.es2.ES2Pipeline
Loading ES2 native library ... prism_es2
GraphicsPipeline.createPipeline failed for com.sun.prism.es2.ES2Pipeline
java.lang.UnsatisfiedLinkError: Can't load library: projectdir/build/libs/amd64/libprism_es2.so
*** Fallback to Prism SW pipeline
Prism pipeline name = com.sun.prism.sw.SWPipeline
GraphicsPipeline.createPipeline failed for com.sun.prism.sw.SWPipeline
java.lang.UnsatisfiedLinkError: Can't load library: projectdir/build/libs/amd64/libprism_sw.so
Graphics Device initialization failed for : es2, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
Caused by: java.lang.RuntimeException: No toolkit found
Found solutions with Gradle
I found two solutions, only the first using a fat JAR:
quick-n-dirty solution with pseudo-launcher class using fat JAR
long term solution with Jmods/modularization (not working with fat JAR for me)
I couln't make the long term solution work with the fat JAR Java-Profi-all.jar. Anyway you can find further infos about the modular solution here:
"Make your app modular" on https://edencoding.com/runtime-components-error/
How to fix "Error: JavaFX runtime components are missing, and are required to run this application" : "In short, you have to compile / run by adding the javafx modules in, either as options passed on the command line, or using a modular project."
Gradle solution without using the Gradle-plugin org.openjfx.javafxplugin
: Task 'run' causes: org.joor.ReflectException: java.lang.NoSuchFieldException: javaExecHandleBuilder - Gluon Mobile Project
quick-n-dirty solution with fat JAR
In order to execute the class ch14_javafx.basics.FirstJavaFxExample with Gradle I wrote the class JfxEdencodingDirtyFixLauncher in the same package:
package ch14_javafx.basics;
public class JfxEdencodingDirtyFixLauncher {
public static void main(String[] args){
FirstJavaFxExample.main(args);
}
}
Additionally I made the following modifications on build.gradle:
A) Ensuring the fitting JRE-version for the used openjfx-version.
sourceCompatibility=1.11
targetCompatibility=1.11
B) manually including the openjfx-JARs and C++ libraries (*.so) to the build-configuration (due to my linux installation):
dependencies
{
...
compile fileTree('/usr/local/manuell/javafx-sdk-11.0.2/lib/') { include '*.jar' }
runtime fileTree('/usr/local/manuell/javafx-sdk-11.0.2/lib/') { include '*' } // also inlcude *.so files for JNI-access
...
The gradle.build-script later copies these *.jar and *.so files to a the subfolder requiredLibs and adds them to the classpath when building the JAR jar:
...
task copyRequiredLibs(type: Copy) {
from configurations.runtime
into "$buildDir/libs/requiredLibs"
}
jar {
dependsOn copyRequiredLibs
baseName = "Java-Profi-all"
manifest {
attributes(
"Created-By" : "Michael Inden",
"Specification-Title" : "Java-Profi",
"Specification-Version" : "3",
"Specification-Vendor" : "Michael Inden",
"Implementation-Title" : "Java-Profi",
"Implementation-Version" : "3",
"Implementation-Vendor" : "Michael Inden",
"Class-Path": configurations.runtime.collect { "requiredLibs/" + it.getName() }.join(' '))
}
// JAR-Dateien mit aufnehmen, dann kann man diese bei Bedarf separat entpacken
into('requiredLibs') {
FileCollection collection = files("$buildDir/libs/requiredLibs")
from { collection.collect { it } }
}
...
For execution of the fat JAR with custom gradle tasks, I added a task definition to the predefined appTasks.txt file:
task JfxEdencodingDirtyFixLauncher (dependsOn: jar, group: 'Java_Profi_Chapter_14') {doLast { executeClass("ch14_javafx.basics.JfxEdencodingDirtyFixLauncher") }}
This task can then be executed using the fat JAR with this command:
gradle JfxEdencodingDirtyFixLauncher
See also:
"Fixing Runtime Components in the short term" on
https://edencoding.com/runtime-components-error/ !
JavaFX 11 : Create a jar file with Gradle : "The final goal is to have the JavaFX modules as named modules on the module path, and this looks like a quick/ugly workaround to test your application. For distribution I'd still suggest the above mentioned solutions."
Error: JavaFX runtime components are missing, and are required to run this application in eclipse
Good Afternoon everyone.
I'm having a problem when I try to run my Java Code as a Runnable Jar file. I'm using Eclipse and I created a normal Java Project. I included the JavaFX jars as a User Libary. The Program runs without a problem when I start it with the IDE. To create the Jar file I use the the build in Export of a Java Project in the Runnable Jar file.
When I check "Extract required libaries into generated JAR" and run it, I get this Error Message:
Error: JavaFX runtime components are missing, and are required to run this application
When I check "Package required libaries into generated JAR" and run it, I get this Error Message:
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:835)
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)
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:835)
Does anyone know, why I cannot run the JAR but in the IDE it runs normally?
I installed JavaFX following the Documentation here https://openjfx.io/openjfx-docs/ .
I found a solution to my Problem. When I Export the Libaries into the Generated Jar I got the Error that the JavaFX Runtime components are missing. I now remembered that I got the same Error in Eclipse before although there was no Error in the Code and I used JavaFX elements. But to get it up and running I had to add VM Arguments. So I only had to write this in the command promt when I wanted to run the program.
Assuming you already are in the directory of your build Jar file:
java --module-path "C:\Path\to\javafx-sdk-13.0.2\lib" --add-modules javafx.controls,javafx.fxml -jar YourJar.jar
It's working now for me. Hope it will help others too.
Best Wishes
Check your built jar file manifest file to see what are its dependencies. There will be an variable called Class-path:
U can do this by right clicking on the jar file and opening with winrar or normal explorer META.INF
If they all begin with libs/ then create an libs folder where your built jar file is located and copy all javafx specified jar files into that folder and then execute
New to Java here. Using IntelliJ. I wrote a simple "helloworld" Spring application that compiles just fine, but when I run it receive the following error:
/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=51884:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -p /Users/winston.kotzan/Development/java-spring-helloworld/bin:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-aop-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-aspects-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-beans-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-context-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-context-indexer-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-context-support-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-core-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-expression-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-instrument-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-jcl-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-jdbc-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-jms-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-messaging-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-orm-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-oxm-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-test-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-tx-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-web-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-webflux-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-webmvc-5.1.3.RELEASE.jar:/Users/winston.kotzan/java/spring-framework-5.1.3/libs/spring-websocket-5.1.3.RELEASE.jar -m SpringHelloWorld/com.wakproductions.MainApp
Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/SQLException
at spring.core#5.1.3.RELEASE/org.springframework.core.Constants.<init>(Constants.java:67)
at spring.beans#5.1.3.RELEASE/org.springframework.beans.factory.xml.XmlBeanDefinitionReader.<clinit>(XmlBeanDefinitionReader.java:102)
at spring.context#5.1.3.RELEASE/org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:83)
at spring.context#5.1.3.RELEASE/org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:133)
at spring.context#5.1.3.RELEASE/org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:622)
at spring.context#5.1.3.RELEASE/org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:518)
at spring.context#5.1.3.RELEASE/org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144)
at spring.context#5.1.3.RELEASE/org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:85)
at SpringHelloWorld/com.wakproductions.MainApp.main(MainApp.java:8)
Caused by: java.lang.ClassNotFoundException: java.sql.SQLException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 9 more
I suspect that it may have to do with the CLASSPATH. I tried setting the CLASSPATH environment variable, as well as adding this to the java command
-cp /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
But that does not seem to work. Might I have the incorrect CLASSPATH?
The comments about the module-info file led me to some clues. I took notice that IntelliJ seems to have created a module-info.java file with the following contents:
module SpringHelloWorld {
requires spring.context;
}
Did not realizing I was compiling a module. I deleted that file along with everything in the bin directory. Then I was able to run it by the Run menu using this option:
I can run it on the command line via:
java -Dfile.encoding=UTF-8 -classpath /Users/.../java-spring-helloworld/bin:/Users/.../<spring-framework-libs>... com.wakproductions.MainApp
I am trying to open a .jar file (https://github.com/ptrckbnck/SQLChecker/releases) on my MAC Mojave 10.14 , I need it for my university course.
What I did:
installed java OpenJDK 11 as suggested here https://solarianprogrammer.com/2018/09/28/installing-openjdk-macos/
java -version
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
But when I run java -jar SQLChecker-1.0.jar I keep on getting the following exception:
Graphics Device initialization failed for : es2, 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:222)
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:834)
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.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)
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:834)
I have read related thread Migration to JDK 11 + JavaFX 11 giving RuntimeException and downloaded also JavaFX 11, namely JavaFX Mac OS X SDK from here https://gluonhq.com/products/javafx/. I also run the following code:
export PATH_TO_FX=my/path/to/javafx-sdk-11/lib
and run HelloWorld test using JavaFX 11 as described here https://openjfx.io/openjfx-docs/. Everything worked fine but did not solve my original problem.
As was suggested by #Drimux in the related thread some libraries are missing in the OpenJDK distribution. He sad that those probably are libprism_es2.dylib, libprism_sw.dylib, libglass.dylib, libjavafx_font.dylib. So I copied those files from the javafx-sdk-11.0.1/lib into /Library/Java/JavaVirtualMachine/jdk-11.0.1.jdk/Contents/Home/lib and tried to run my .jar file again. Got new exception:
GLFactory.static - Platform: Mac OS X - not available: com.sun.prism.es2.MacGLFactory
java.lang.ClassNotFoundException: com.sun.prism.es2.MacGLFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at com.sun.prism.es2.GLFactory$FactoryLoader.run(GLFactory.java:108)
at com.sun.prism.es2.GLFactory$FactoryLoader.run(GLFactory.java:100)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at com.sun.prism.es2.GLFactory.<clinit>(GLFactory.java:97)
at com.sun.prism.es2.ES2Pipeline.<clinit>(ES2Pipeline.java:76)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:187)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:91)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
at java.base/java.lang.Thread.run(Thread.java:834)
java.lang.ClassNotFoundException: com.sun.glass.ui.mac.MacPlatformFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:42)
at com.sun.glass.ui.Application.run(Application.java:144)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:258)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:269)
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:834)
Failed to load Glass factory class
Exception in thread "main" java.lang.NullPointerException
at com.sun.glass.ui.Application.run(Application.java:144)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:258)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:269)
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:834)
This didn't fix the problem. If you need more information please request.
What else should I try?
If you have downloaded the jar from the first test release, when running it like:
java -jar SQLChecker-1.0.jar
you will get the posted exception.
As a first easy fix, if you have downloaded JavaFX 11 SDK, run this instead:
java --module-path /path-to/javafx-sdk-11/lib --add-modules javafx.controls,javafx.fxml -jar SQLChecker-1.0.jar
You can read about why you need those VM arguments here.
In any case, you shouldn't copy the native files from the JavaFX SDK to the JDK.
New releases
But there are two more new releases of SQLChecker.
If you try the last one:
java -jar SQLChecker-1.0.3.jar
that will work fine, without adding those extra arguments.
So what has changed?
They are distributing a fat Jar with the Maven shade plugin, and in order to work on JavaFX 11 on any platform, you need to include not only the jars, but also the native libraries.
As you can see, in this commit, by including the classifier tag for javafx.graphics, they added the required native libraries for Windows, Linux and Mac, as it has been also stated in this question.
If you want to know more about how to create a fat jar, see this doc.