84

I've downloaded OpenJDK 8 today via sudo apt-get install openjdk-8-jdk and it seems like JavaFX is not included in it.

> java -version
openjdk version "1.8.0_66-internal"
OpenJDK Runtime Environment (build 1.8.0_66-internal-b17)
OpenJDK Server VM (build 25.66-b17, mixed mode)

I've installed E(fx)clipse in latest Eclipse (Eclipse Mars) too, but I'm still getting message javafx couldn't be resolved.

Samuel Philipp
  • 10,631
  • 12
  • 36
  • 56
Nikola Stojaković
  • 2,257
  • 4
  • 27
  • 49

2 Answers2

155

According to the packages list in Ubuntu Wily Xenial Bionic there is a package named openjfx. This should be a candidate for what you're looking for:

JavaFX/OpenJFX 8 - Rich client application platform for Java

You can install it via:

sudo apt-get install openjfx

It provides the following JAR files to the OpenJDK installation on Ubuntu systems:

/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jfxswt.jar
/usr/lib/jvm/java-8-openjdk-amd64/lib/ant-javafx.jar
/usr/lib/jvm/java-8-openjdk-amd64/lib/javafx-mx.jar

If you want to have sources available, for example for debugging, you can additionally install:

sudo apt-get install openjfx-source
MWiesner
  • 8,868
  • 11
  • 36
  • 70
  • 2
    which one do you import to use the the javafx functions? – Jürgen K. Aug 09 '16 at 13:55
  • @JürgenK. I usually let my IDE decide, but I guess `jfxrt.jar` is the one you are looking for. – MWiesner Aug 12 '16 at 12:43
  • 2
    For what it's worth, I suspect installing the `openjfx` package may only affect installed applications, rather than providing access in a dev environment.. I saw an error flash about missing "javafx" when running FileBot on Mint 18, which I resolved by installing this. From the dev side this would be (at most) a runtime dependency, which isn't generally installed directly into the main system. **Or** am I mistaken here..? –  Feb 20 '17 at 16:45
  • 9
    If you are using IDEA, make sure remove the currently selected JDK in Project Structure, SDK by clicking red minus button then re-add the JDK so JavaFx related files/classpath loaded by IDEA. – Vina Mar 02 '17 at 20:43
  • On Raspberry Pi I had to follow the instructions in this answer to avoid some missing library errors https://stackoverflow.com/a/52018995/2407742 – iyrin Aug 25 '18 at 17:24
  • works for me. However I've downloaded javafx unpacked tar.gz and copied manually. – Vadim Dec 02 '18 at 07:36
  • Note that this will download the latest version of OpenJFX and there seem to be no way to install the older one, see https://bugs.launchpad.net/ubuntu/+source/openjfx/+bug/1799946. – Line Jan 03 '19 at 12:01
  • @MWiesner, your suggestion to import jfxrt.jar is contrary to what this says: https://wiki.openjdk.java.net/display/OpenJFX/Using+an+IDE#UsinganIDE-JDK-8Only:Deletejfxrt.jar(ormoveittoadifferentdirectory) I have just done a clean install of ubuntu 18.4 and openjfx8 (held at version 8). It doesn' work for me in any case, so I am trying to see what I really need to do - why is there a difference between your suggestion and the article? – pateksan Feb 05 '20 at 01:02
  • 1
    If it matters I checked the properties of `/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar` and it turns out it's a broken link, with link target showing as `../../../../../../share/java/openjfx/jre/lib/ext/jfxrt.jar` (copied exactly from the Properties) - could this be my problem? If so, where should it be pointed? – pateksan Feb 05 '20 at 01:09
21

I use ubuntu 16.04 and because I already had openJDK installed, this command have solved the problem. Don't forget that JavaFX is part of OpenJDK.

sudo apt-get install openjfx
MWiesner
  • 8,868
  • 11
  • 36
  • 70
Loich
  • 813
  • 11
  • 18