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.
Related
I'm using jpackage (part of jdk14+) to build an MSI for windows installation of my java application. Everything packages and installs fine, but when I go to run the .exe it throws an exception while trying to initialize Sentry.
Exception in thread "main" java.lang.NoSuchMethodError: 'void jdk.internal.reflect.Reflection.registerMethodsToFilter(java.lang.Class, java.lang.String[])'
at sun.misc.Unsafe.<clinit>(Unsafe.java:59)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
at com.google.gson.internal.reflect.UnsafeReflectionAccessor.getUnsafeInstance(UnsafeReflectionAccessor.java:70)
at com.google.gson.internal.reflect.UnsafeReflectionAccessor.<init>(UnsafeReflectionAccessor.java:34)
at com.google.gson.internal.reflect.ReflectionAccessor.<clinit>(ReflectionAccessor.java:36)
at com.google.gson.internal.ConstructorConstructor.<init>(ConstructorConstructor.java:51)
at com.google.gson.Gson.<init>(Gson.java:206)
at com.google.gson.GsonBuilder.create(GsonBuilder.java:597)
at io.sentry.EnvelopeReader.<init>(EnvelopeReader.java:28)
at io.sentry.SentryOptions.<init>(SentryOptions.java:89)
at io.sentry.SentryOptions.empty(SentryOptions.java:1559)
at io.sentry.NoOpHub.<init>(NoOpHub.java:15)
at io.sentry.NoOpHub.<clinit>(NoOpHub.java:13)
at io.sentry.Sentry.<clinit>(Sentry.java:24)
This is using the latest sentry 5.2.0 library (tested all the way back to 4.2 and it still has the error though), and have tested JDK 14 through 17 to see if any of them work, which they don't.
Everything works fine if I'm running the .jar with java -jar program.jar, but it seems like jpackage creates an executable that doesn't work quite the same as simply running java.
The call to jpackage needed --add-modules jdk.internal.vm.compiler to fix this in JDK14, and by JDK17 it needs to be --add-modules jdk.unsupported instead.
I am trying to use jlink as part of the javafx-maven-plugin plugin to create a runtime image with AdoptOpenJDK 15. For some reason I end up getting the following error during the jlink goal:
Error: java.io.UncheckedIOException: java.nio.file.AccessDeniedException: ...\target\image\bin\javaw.exe
javafx:run, however, works fine.
Note: The path to the project has been omitted from the error message.
Some antiviruses can block the creation of executable files. Check if this is the case and configure your antivirus to exclude ...\target\image\bin\javaw.exe from being checked, or to trust the jlink process to write whatever it wants.
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
I am getting an odd error when I try to run a program that I'm trying to bring to Linux. I am able to compile/run without problems on Windows and OSX, but am seeing this problem on Ubuntu.
When I build/run/debug the program through Netbeans, everything is hunky dorey. It runs, all the tests in its suite complete, etc. When I try to run it independent of the IDE though, I run into the following problems:
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:243)
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 javafx.embed.swing.JFXPanel.lambda$initFx$1(JFXPanel.java:224)
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)
I have been banging my head against this for a few hours, and any thoughts/assistance would be much appreciated.
In my case, this problem occurs when I used oracle JDK and openJFX. When I switched to openJDK problem was solved (only on Ubuntu, Windows does not suffer from this problem).
If this will not help, you can try to change default gtk version for javaFX
-Djdk.gtk.version=2 //you can add as JVM option
The default version of GTK of javaFX was recently changed from gtk2 to gtk3. This fact causes many issues.
I am using Postman alongside a JAR file that runs a REST service that holds some contacts. However when I try to run the JAR file by using: java -jar ContactListRESTService.jar in Powershell, I am seeing a bunch of errors that Apache Tomcat could not run. Postman also doesn't recognize the localhost.
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:159)
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletCntainer.java:159) ~[spring-boot 1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
I have tried uninstalling and reinstalling JAVA SE per some guidance from a mentor with no results.
If anyone can point me in the right direction please.