0

I made a small app using Swing and exported to jar. Now if I double-click the file on Linux or Windows, it starts as normal (exactly the same file).

I want to achieve the same thing with JavaFX. However since JavaFX files are platform dependent (afaik), do I have to export separate jars for each platform with their required files?

The googling I did did not give me a definitive answer about JavaFX being consistently included in most popular JREs for each platform. Most of the answers I found are outdated and/or contradicting one another. And perhaps I am missing the correct terminology that would give me the results.

I want to target primarily Linux and Windows without the user needing to install anything other than the easiest JRE option (Oracle JRE on Windows, OpenJRE on Linux, I believe). Most apps that I will be making will be only small apps.

Also does using Maven or Gradle help in this matter?

So far I have used Eclipse IDE.

  • Short answer: yes. JavaFX uses native libraries. Instead of deploying a large .jar, consider [linking an executable image](https://stackoverflow.com/questions/53453212/how-to-deploy-a-javafx-11-desktop-application-with-a-jre) and distributing that. – VGR Apr 30 '21 at 11:29
  • If I understand it correctly, this way I can create a self contained app that includes my Java code, any Java libraries, required native libraries and required parts of the JRE? And the target machine does not need to have a JRE installed? This way I also have to create an archive for each platform, right? – TurgonTheKingOfGondolin May 04 '21 at 13:24
  • Yes, that’s correct. – VGR May 04 '21 at 13:50

1 Answers1

0

I created a JavaX app a while back using JDK 1.8.0_181 which included everything I needed in the jfxrt.jar. I have not run my app on other platforms but I cannot imagine JavaFX breaking the cross-platform nature of Java.

I used Maven but it won't make a difference regarding compatibility.

dependencies

Adriaan Koster
  • 15,870
  • 5
  • 45
  • 60