JavaFX on Linux is showing a “Graphics Device initialization failed for : es2, sw”

匿名 (未验证) 提交于 2019-12-03 01:57:01

问题:

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:

I solve this issue adding the libswt-gtk-3-java and gkt3 to my system.



回答3:

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



回答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:

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:



回答6:

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).



回答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:

You need to install OpenJFX:

apt-get install openjfx 

and then run the program.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!