How to deploy JavaFX 15 Code to JAR with Java 15 - java

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

Related

Error initializing QuantumRenderer: no suitable pipeline found in Eclipse JavaFX

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.

Running .jar with CLI

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.

How to solve "Graphics Device initialization failed for : d3d, sw" when running a java Jar file with JavaFx

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

Run JavaFX with Visual Studio Code Remote Extension

I'm already trying for a few hours to run a JavaFX application with the help of the Visual Studio Remote Development extension within a Docker Container.
I want to forward the graphic of the application with the help of X11. I already integrated the required packages for X11 in the container, set the DISPLAY environment variable and mounted the X11 socket in the container (/tmp/.X11-unix/).
Unfortunately, it won't work like that... Whenever I try to run the application, I get the following error message:
root#c0699153fc1c:/workspaces/JavaFX/src# java --module-path /usr/share/openjfx/lib/ --add-modules javafx.controls,javafx.fxml HelloWorldApplication.java
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 javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:222)
at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:260)
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.launchApplication1(LauncherImpl.java:678)
at javafx.graphics/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 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)
... 1 more
Exception in thread "main" java.lang.RuntimeException: No toolkit found
I'm using openjdk:11 as base image for the docker container and installed the following packages inside of it:
openjfx
libx11-dev
libxext-dev
libxrender-dev
libxtst-dev
I previously already tried to run IntelliJ within a Docker container, which is working fine. The GUI gets forwarded to my Display and also JavaFX applications are working fine in there.
I would appreciate any help on this matter. Maybe I oversee something.
EDIT:
I think I found the problem. It seems like OpenJDK:11 and OpenJFX do not work correctly, even though I followed tons of tutorials...
So what I did now is that I exported the JDK, which comes with IntelliJ IDEA and mounted it into the container, which gets created of VS Code. After compiling the .java file with the mounted compiler and executing it, it worked flawlessly.
So now my only problem is, that I need a working setup within VS Code to get JavaFX applications working -> so a proper OpenJDK and OpenJFX configuration.
Finally, I was able to fix the problem. So the solution was:
I created an own Dockerfile, where I took the openjdk:12 image as base and copied the JavaFX libraries (which I got from here: https://gluonhq.com/products/javafx/) into the container. Additionally, I added all required packages for X11 (mentioned above).
In VS Code, after the container has been started, I simply had to add the libs to the "Referenced Libraries".
Afterwards, I had to adjust the launch.json and added the following vmArgs:
"vmArgs": "--module-path <Path-to-FX-Folder> --add-modules javafx.controls"
Now when I run the application, the window is going to be created and shown on my DISPLAY.

Unity-Android _ CommandInvokationFailure: Unable to convert classes into dex format

i'm using Windows 7, jdk 1.8.0 (64bit), jre 8 (64bit), Unity Pro 4.3.4f1 and Android SDK 22.6.1
All are updated softwares.
All works fine but when i use StartApp sdk, this error comes. No extra plugin is used, only the SDK provided by the StartApp ad.
Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:\Program Files\Java\jdk1.8.0\bin\java.exe -Xmx1024M -Dcom.android.sdkmanager.toolsdir="D:/android-sdks\tools" -Dfile.encoding=UTF8 -jar "C:/Program Files (x86)/Unity/Editor/Data/BuildTargetTools/AndroidPlayer\sdktools.jar" -
stderr[
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/a$1;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:685)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at SDKMain.main(SDKMain.java:129)
1 error; aborting
]
I already tried JAVA_OPT and JAVA_HOME solutions. But still couldn't solved
I ran into this using IntelliJ 13.1.4, JDK 1.6 but I would guess that this is caused by the same thing on any other IDE -> classes.jar is referenced/included more than once.
Check and make sure that the classes.jar you added to the project (from Unity\Editor\Data\PlaybackEngines\androidplayer\bin\classes.jar) isn't referenced/included more than once. If you go into File->Project Structure:
There should only be one "classes" under libraries.
There should be NO reference to classes under Artifacts (Artifacts is used to create the plugin .jar file.)
Check out this related answer ->
https://stackoverflow.com/a/8437996/3464367
My issue was actually related to having duplicate files. Well not really duplicates, but I had 2 adMob sdk packages (different versions), that were getting into conflict. After deleting the older one, everything was fixed. Are you using any 3rd party SDK's or something similar, if so, try removing them if possible and see if the issue persists. Try to find out which part of the code is causing this to happen. You could ultimately try to compile an empty project just for testing.
Today I solved similar problem of Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details. with adding .jar file into Plugins\Android\
I got different kind of errors:
Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000 ...
Caused by: com.android.dx.cf.iface.ParseException: class name (ht/stringing/test) does not match path (src/ht/stringing/test.class)
My result working solution was similar to this:
Code lives here:
verysimple\src\ht\stringing\test.java
I do:
> javac -classpath "c:\Android\sdk\platforms\android-15" ht\stringing\test.java
> jar cvf ..\dist\verysimple.jar ht\stringing\test.class
> copy ..\dist\verysimple.jar c:\ExUnityApp\Assets\Plugins\Android
Don't forget to compare your 'Minimum Api Level' in Player Setting. For me it was Android 4.0.3 ... (15)

Categories

Resources