Linux 上的 JavaFX 显示“图形设备初始化失败:es2,sw”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21185156/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 01:52:00  来源:igfitidea点击:

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

javalinuxjavafxjava-8

提问by VeryNiceArgumentException

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.

我刚刚开始在 Linux 上编码/测试 JavaFX 的东西,我在启动一个简单的应用程序时遇到了错误。我在 Foruns 中发现很多人对此表示关注,但我可以找到有关其发生原因的明确解释。我想了解我的场景中缺少什么才能使其正常工作。

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)

回答by assylias

You should have a look at this related bugfor help on how to troubleshoot your issue. In summary, the recommendations are:

您应该查看此相关错误,以获取有关如何解决问题的帮助。总之,建议如下:

  • run the application with the -Dprism.verbose=trueflag
  • 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
  • 运行带有-Dprism.verbose=true标志的应用程序
  • 检查产生的详细日志
  • 它可能指向缺少的 garphics 库:在 linux 上运行 JavaFX 需要 GTK 2.18

回答by Wesley Gomes

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

我解决了这个问题,将 libswt-gtk-3-java 和 gkt3 添加到我的系统中。

回答by Lera Sinevich

The problem can be in your old JRE version, which doesn't contain all the necessary libraries, such as libprism_es2.soor 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.javaclass from console

问题可能出在您的旧 JRE 版本中,该版本不包含所有必需的库,例如libprism_es2.solibglass.so,它们应该位于/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64. To check if this is the issue compile your Main.java控制台的类中

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.

输出应该是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.

从 Oracle 官方网站下载最新的 JRE,并将 lib 文件夹复制到您当前的 JRE 位置。那应该就够了。

回答by Pragalathan M

It was failing for me because i didnt have gtk libs. After enabling -Dprism.verbose=trueas mentioned by @assylias

它对我来说失败了,因为我没有 gtk 库。-Dprism.verbose=true如@assylias 所述启用后

i could find and installed the following packages.

我可以找到并安装以下软件包。

sudo apt-get install libgtk2.0-bin libXtst6 libxslt1.1

It fixed the problem

它解决了问题

回答by cubuspl42

In my case, the issue was missing 32-bit dependencies on 64-bit distribution.

就我而言,问题是缺少对 64 位发行版的 32 位依赖项。

For me, the following command fixed the issue on Ubuntu 16.10 (x86-64):

对我来说,以下命令修复了 Ubuntu 16.10 (x86-64) 上的问题:

sudo apt-get install libgtk2.0-0:i386 libxtst6:i386

Related questions:

相关问题:

回答by Ajay

You need to install OpenJFX:

您需要安装 OpenJFX:

apt-get install openjfx

and then run the program.

然后运行程序。

回答by Marco Doveri

For anyone in trouble with this problem using Eclipse, the solution can be found adding -Dprism.verbose=trueto JVM arguments into the "Debug options" window (like already mentioned in other replies). After that, missing libraries will be listed into the console.

对于使用 Eclipse 遇到此问题的任何人,可以找到解决方案,将-Dprism.verbose=trueJVM 参数添加到“调试选项”窗口中(就像其他回复中已经提到的那样)。之后,缺少的库将列在控制台中。

However, I solved simply downloading and installing Java from the Oracle's official page.

但是,我解决了简单地从 Oracle 的官方页面下载和安装 Java 的问题

https://www.java.com/it/download/

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

之后,您将在下面找到 Java 文件夹/usr/java/jre-1.8.X_XXX(这取决于您下载的版本)。

Then, open Eclipse and from Window->Preferences->Java->Installed JREs add a new JRE using the path mentioned above.

然后,打开 Eclipse 并从 Window->Preferences->Java->Installed JREs 使用上述路径添加一个新的 JRE。

Now, set workspace's JRE on the build path of your project.

现在,在项目的构建路径上设置工作区的 JRE。

It should work now.

它现在应该可以工作了。

You can also set the JRE only for a specific project, in my case was more useful as general setting.

您还可以仅为特定项目设置 JRE,在我的情况下作为一般设置更有用。

System: Fedora 26 64 bit. (jre1.8.0_144).

系统:Fedora 26 64 位。(jre1.8.0_144)。

回答by Arnold Braine

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.

现在从oracle下载新的jdk,将丢失的文件从那里复制到文件丢失的文件夹中。

I was missing 3 files in total that i copied, this may vary from person to person

我总共丢失了 3 个我复制的文件,这可能因人而异

Hope this helps some of you guys

希望这对你们中的一些人有所帮助

回答by Lonzak

The -Dprism option helped then a list of files was printed out:

-Dprism 选项有助于打印出文件列表:

Can not open shared object file: File or directory not found.

无法打开共享对象文件:找不到文件或目录。

  1. libgtk-x11-2.0.so.0
  2. libXxf86vm.so.1
  3. libGL.so.1
  1. libgtk-x11-2.0.so.0
  2. libXxf86vm.so.1
  3. libGL.so.1

After installing the packages it did work.

安装软件包后,它确实起作用了。

回答by Adam Lee

For those on ArchLinux: pacman -Sy java-openjfxdoesn't install the necessary gtk2package (GTK3 doesn't count).

对于 ArchLinux 用户: pacman -Sy java-openjfx不安装必要的gtk2包(GTK3 不算在内)。