48

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)
Nikos Paraskevopoulos
  • 39,514
  • 12
  • 85
  • 90

17 Answers17

27

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 graphics library: GTK 2.18 is required to run JavaFX on linux
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
assylias
  • 321,522
  • 82
  • 660
  • 783
  • 4
    Not sure why but -Dprism.verbose=true is not adding any extra information on the error message. Anyway, graphic library is for sure a problem I have (current GTK 2.16). I'll try to update that and get it working. Thanks assylias! – VeryNiceArgumentException Jan 20 '14 at 14:02
  • 1
    @assylias I am facing the similar problem. Can you please tell me with which application do I have to write this command `-Dprism.verbose=true` . I am new at linux. So i dont have any idea how to rectify the issue. – Harshita Sethi Jul 16 '15 at 10:22
  • 3
    @HARSHITASETHI you run your application with `java -jar blabla.jar` just add `-Dprism.verbose=true`. If you run it from your IDE you need to add that to the JVM parameters. – assylias Jul 16 '15 at 11:44
  • 1
    Ok got it. Thanks. :) – Harshita Sethi Jul 17 '15 at 06:33
  • 1
    @assylias I am getting similar kind of problem. The link you provided in the answer is no more active. I also installed GTK on my raspberry pi. The problem still persists. – kk. Jun 03 '16 at 11:18
  • 1
    @KrishnaKuntala I have updated the link. I don't run JavaFX on linux so can't really help. – assylias Jun 03 '16 at 11:49
  • 1
    This answer, like all the current answers here, is long out of date. If, like the original questioner, you're using OpenJDK 8, you need to install the OpenJFX for Java 8. – Lambart Oct 08 '19 at 10:27
26

You need to install OpenJFX:

apt-get install openjfx

and then run the program.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Ajay
  • 367
  • 3
  • 6
  • 3
    @FearX this answer is out-of-date, as are most of the answers here. The listed command will install the _latest_ openjfx, which is incompatible with Java 8. I'm about to post an answer that should solve the problem... if you're using Ubuntu (otherwise you can use Oracle JDK 8, if that's compatible with your philosophy etc.) You need to specifcally request the Java 8 version. – Lambart Oct 08 '19 at 10:25
11

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

Wesley Gomes
  • 119
  • 1
  • 3
8

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.

Lera Sinevich
  • 164
  • 3
  • 10
  • 8
    Great answer. On Fedora one can find out the name of the package to install by running `dnf whatprovides `. And then install it again by dnf. I my case: `sudo dnf install java-1.8.0-openjdk-openjfx`. – czerny Oct 23 '17 at 01:29
  • 2
    **Notice** however that **installing it** (named just `openjfx` on Fedora 29) **is not enough** (at least on Fedora 29). Read the distro specific readme file, and given that the preamble part ends with a line containing `something` and has nothing extra at the end you can install with `sed 1,/something/d /usr/share/doc/openjfx/README.fedora | sh`. – hlovdal Dec 13 '18 at 21:09
6

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

Pragalathan M
  • 1,673
  • 1
  • 14
  • 19
5

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.

Lambart
  • 1,985
  • 2
  • 21
  • 37
4

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

3

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:

Community
  • 1
  • 1
cubuspl42
  • 7,833
  • 4
  • 41
  • 65
3

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

Adam Lee
  • 1,784
  • 1
  • 11
  • 15
3

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

Paul Bormans
  • 1,292
  • 16
  • 22
2

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

SilverNak
  • 3,283
  • 4
  • 28
  • 44
1

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

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

After installing the packages it did work.

Lonzak
  • 9,334
  • 5
  • 57
  • 88
1

Assuming you have setup JavaFX correctly, all you have to is add to VM Options the following line:

-p %path to javafx%/lib --add-modules javafx.controls,javafx.fxml

To edit VM Options in IntelliJ, you need to open Run/Debug Configurations.

(Of course, change %path to javafx% so it points to your JavaFX folder location)

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
1

I was getting this error message on Ubuntu 20.04. Here is what has worked for me. I went to Zulu to download the jdk 11. I selected the java version to be 11 and Java package as JDK FX. After installing the .deb file, I set up $JAVA_HOME on .zshrc:

export JAVA_HOME=/usr/lib/jvm/zulu-fx-11-amd64
export PATH=$JAVA_HOME/bin:$PATH

This has solved my issue.

theAntonym
  • 39
  • 1
  • 8
1

I was having this problem too. The issue for me was that I downloaded the aaarch64 version my fx global libraries. All you have to do is to download the x64 version of it. Try running your code again, it will probably work, it did for me. :)

Link to download the fx lib files: https://gluonhq.com/products/javafx/

1

The JavaFX aarch64 version is the cause of this problem in my computer. Problem solved by switching to x64 version.

Shasha Wu
  • 11
  • 1
0

I had the same error, but it was with a straightforward FX app, and I checked that this dependency was the main cause of this error:

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-graphics</artifactId>
    <version>17.0.1</version>
    <classifier>linux</classifier>
</dependency>

Once I have commented, and also commented, this "requires javafx.graphics;" from module-info, the app starts as expected...

Yes, it was weird, but it was how it working here

Bruno Penha
  • 57
  • 1
  • 8