问题
I've just started coding/testing JavaFX stuff on Linux and I'm facing an error at time to start a simple app. I found many people concerning about that in Foruns but I could find a clear explanation about the reasons why it happens. I'd like to understand what is missing in my scenario to get it working.
Any suggestion will be really apreciated.
Env info:
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b123)
Java HotSpot(TM) Client VM (build 25.0-b65, mixed mode)
Linux MYServer 2.6.21-1.3228.fc7 #1 SMP Tue Jun 12 15:37:31 EDT 2007 i686 i686 i386 GNU/Linux
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:300)
at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:244)
at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:179)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:210)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:653)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:314)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:305)
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 sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:98)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:128)
at java.lang.Thread.run(Thread.java:744)
Exception in thread "main" java.lang.reflect.InvocationTargetException
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 sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: No toolkit found
at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:191)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:210)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:653)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:314)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:305)
回答1:
You should have a look at this related bug for help on how to troubleshoot your issue. In summary, the recommendations are:
- run the application with the
-Dprism.verbose=true
flag - check the detailed log that is produced
- it may point to a missing garphics library: GTK 2.18 is required to run JavaFX on linux
回答2:
You need to install OpenJFX:
apt-get install openjfx
and then run the program.
回答3:
I solve this issue adding the libswt-gtk-3-java and gkt3 to my system.
回答4:
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.
To check if this is the issue compile your Main.java
class from console
javac Main.java
java -Dprism.verbose=true Main
The output should possibly be java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/libprism_es2.so
.
Download latest JRE from the official Oracle website and copy lib folder to your current JRE location. That should be enough.
回答5:
It was failing for me because i didnt have gtk libs. After enabling -Dprism.verbose=true
as mentioned by @assylias
i could find and installed the following packages.
sudo apt-get install libgtk2.0-bin libXtst6 libxslt1.1
It fixed the problem
回答6:
In my case, the issue was missing 32-bit dependencies on 64-bit distribution.
For me, the following command fixed the issue on Ubuntu 16.10 (x86-64):
sudo apt-get install libgtk2.0-0:i386 libxtst6:i386
Related questions:
- Ubuntu 64 bit Machinarium: error while loading shared libraries: libgtk-x11-2.0.so.0
- Can't find/install libXtst.so.6?
回答7:
I found a solution that worked for me, the stacktrace has more to it than this line:
Graphics Device initialization failed for : es2, sw.
scroll up and you will find a line that looks like follow:
Caused by: java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/libglass.so
Now download the new jdk from oracle, copy the missing file from there into the folder where the file is missing.
I was missing 3 files in total that i copied, this may vary from person to person
Hope this helps some of you guys
回答8:
For those on ArchLinux:
pacman -Sy java-openjfx
doesn't install the necessary gtk2
package (GTK3 doesn't count).
回答9:
On brand new Ubuntu 18.10 install i ran into the same issue when a preview of a markdown file is rendered in pycharm (community edition).
I downloaded an oracle JRE (jre1.8.0_201) and used that instead of the jre that is shipped with pycharm but i got the same problem again.
Then added the -Dprism.verbose=true option which revealed that libgtk-x11-2.0.so.0 is missing. Finally sudo apt-get install libgtk2.0-0 resolved the issue.
Thanks, Paul
回答10:
For anyone in trouble with this problem using Eclipse, the solution can be found adding -Dprism.verbose=true
to JVM arguments into the "Debug options" window (like already mentioned in other replies). After that, missing libraries will be listed into the console.
However, I solved simply downloading and installing Java from the Oracle's official page.
https://www.java.com/it/download/
After that, you will find the Java folder under /usr/java/jre-1.8.X_XXX
(it depends on which version you've downloaded).
Then, open Eclipse and from Window->Preferences->Java->Installed JREs add a new JRE using the path mentioned above.
Now, set workspace's JRE on the build path of your project.
It should work now.
You can also set the JRE only for a specific project, in my case was more useful as general setting.
System: Fedora 26 64 bit. (jre1.8.0_144).
回答11:
The -Dprism option helped then a list of files was printed out:
Can not open shared object file: File or directory not found.
- libgtk-x11-2.0.so.0
- libXxf86vm.so.1
- libGL.so.1
After installing the packages it did work.
回答12:
If you, like the original questioner, are using Java 8, you need to either install Oracle JDK 8 (good luck), or install OpenJFX 8 to go along with the OpenJDK 8.
At present, I can provide the exact instructions for Ubuntu 18.x. They may also work on other Debian-based systems. If you're using another OS, perhaps the package names listed below will lead you in the right direction.
First, you need to discover which versions of OpenJFX are available on your distribution. Run this from the command line:
$ apt-cache policy openjfx
In the Version table section, you'll likely see two choices. I currently see 11.0.2+1-1~18.04.2
and 8u161-b12-1ubuntu2
. The version beginning with 11 is the default, even though you've (presumably) installed openjdk-8-jdk
. You'll want the version beginning with the number 8. At the time of writing, this is 8u161-b12-1ubuntu2
.
To install OpenJFX and the related packages (assuming you're doing development work), first make sure you've uninstalled any Java 11-based packages, because they'll (un)happily coexist with JDK 8, and cause you lots of problems.
$ sudo apt remove openjfx openjfx-source libopenjfx-java libopenjfx-jni
Next, install the correct versions (substituting whatever version you saw listed in the policy
query for 8u161-b12-1ubuntu2
):
$ sudo apt install openjfx=8u161-b12-1ubuntu2 openjfx-source=8u161-b12-1ubuntu2 libopenjfx-java=8u161-b12-1ubuntu2 libopenjfx-jni=8u161-b12-1ubuntu2
Update: I noticed the next day that sudo apt upgrade
(or automatic system updates) would "upgrade" the jfx packages I'd so carefully chosen the version for. Here's how to prevent that from happening:
$ sudo apt-mark hold openjfx openjfx-source libopenjfx-java libopenjfx-jni
openjfx set on hold.
openjfx-source set on hold.
libopenjfx-java set on hold.
libopenjfx-jni set on hold.
You can run sudo apt showhold
any time to list the packages that are being held back.
Having those old-but-good packages installed resolved all the problems for me. I hope they can help you as well.
回答13:
If you have openjdk, try change to jdk. I change java-8-openjdk to java-8-jdk. It fixed my problem. OpenJDK, in contrast to Oracle JDK, does not contain some proprietary code, for example, the deployment component (Java Web Start, Plugin) is completely missing from it. In addition, the implementation of some algorithms for JDK and OpenJDK is different, since in the closed part the source code is used whose license does not allow their free distribution.
来源:https://stackoverflow.com/questions/21185156/javafx-on-linux-is-showing-a-graphics-device-initialization-failed-for-es2-s