6

Is there any javafx/OpenJFX dependency which can be used directly in the pom file so that it works with OpenJDK 8? Or any workaround (without installing anything) which works with OpenJDK 8?

I have gone through a lot of similar questions on SO, but the solution to use JFX/OpenFX with OpenJDK 8 is either to install the openjfx package in Ubuntu OR use Oracle JDK 8. Unfortunately I cannot do both. I am using OpenJDK 8 and need to use javafx/OpenJFX within my swing application. The OpenJDK does not contain jfxrt.jar in its ext folder (as in case of Oracle JDK 8), and the versions of OpenJFX start from Java 9/10. And on trying to compile I get class file has wrong version 54.0, should be 52.0 which is expected as it is build with Java 10

Any leads would be really helpful. Thanks!

I have already gone through the below links

Why is JavaFX is not included in OpenJDK 8 on Ubuntu Wily (15.10)?

"class file has wrong version 54.0, should be 52.0" while trying to build JavaFX application

"class file has wrong version 54.0, should be 52.0" while compiling javaFX project

How to find out JavaFX version

2 Answers 2

3

Why don't you just use, e.g., https://bell-sw.com/pages/downloads/#/java-8-lts and download the full Java version (not standard). It should already contain JavaFX and is one of the many OpenJDK 8 versions floating arround.

Sign up to request clarification or add additional context in comments.

4 Comments

Well, which JDK to use is not in my control. It is decided at organization level and we only have the option to use that pearticular version of OpenJDK (openjdk-1.8.0.272)
"Liberica Full JDK 8u282+8 x86 64 bit for Linux" is one instance of OpenJDK. Who told you that you have to pick a specific provider (which you did not mention in your post anyway)
That "one instance" of OpenJDK is not available in my system, and I cannot install it. If you know of a way to get this running via OpenJDK 8, it would be helpful.
What are you actually talking about? You have to distinguish between the open sources of OpenJDK and the various distributions built from these sources by different vendors. If you say "get this running via OpenJDK 8" this sentence is meaningless because it does not specify a distribution. Liberica, Zulu, Adoptium,... are all OpenJDKs and satisfy your criteria.
2

Is there any javafx/OpenJFX dependency which can be used directly in the pom file so that it works with OpenJDK 8?

AFAIK, no. There are org.openjfx artifacts for OpenJFX 11 onwards, but they won't work with Java 8. (The class file version will be wrong.)

Or any workaround (without installing anything) which works with OpenJDK 8?

I think you will need to build your own copy of OpenJFX from source, and (touch wood) "package it" with your application1.

(The following is purely based on reading the OpenJFX build instructions. I have not tried this out.)


So if you want to build a stand-alone OpenJFX 8 for use with OpenJDK 8, then you should try the following build instructions on the OpenJFX wiki:

The result of the build is (apparently) a ZIP file that is designed to be "overlayed" onto a JRE installation.

You may be able to repackage that into JARs and native libraries that you can include in your application.


For OpenJFX 9 and later, the build instructions are here:

Apparently, for N >= 9, OpenJFX version N is supposed to be supported for OpenJDK N and OpenJDK N - 1. So if that is accurate, you should be able to build OpenJFX 9 for OpenJDK 8. On the other hand, the build instructions talk about generating modules, and module support is only available in Java 9 and later. However it is still worth a try (IMO).


1 - Options include 1) creating a custom Debian package(s) (or RPMs) ... analogous to the existing Ubuntu packages, 2) incorporating the relevant classes and native libraries into your application JAR, or 3) adding them to your applications classpath and library load path. You may need to experiment.

1 Comment

Thanks Stephen. I will try this out and let you know whether it works or not! Thanks again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.