1

I want to write my first JavaFX 8 application (doing my first experiments with e(fx)clipse, etc.) and have a few concerns about platform independence.

JavaFX 8 is a part of the Oracle JRE, which is the most used JRE on Windows. Therefore, I do not really bother here, since JavaFX will be installed on nearly every Windows machine running Java 8.

But on Ubuntu and other *nix, OpenJDK is often used as Java distribution. Since openjfx is separated from open-jdk-8-*, many will not have JavaFX installed by default.

I thought of:

  • Writing an install script that calls sudo apt-get install openjfx (which I would like to avoid, since I would like the executable .jar to be runable on its own, without script)
  • Shipping a JavaFX distribution (i.e., its .jars) with my applications (but I read that this should not be done)

Both ideas do not seem very promising...

Since I hope that there are some JavaFX pros out there, i hope that someone can help me with "What are the best possibilities to ensure that my JavaFX application will run fine, both on Windows and Ubuntu?" What are state-of-the-art techniques on how to tackle this problem?

Markus Weninger
  • 11,931
  • 7
  • 64
  • 137
  • 1
    Also consider [tag:java-web-start]. – trashgod Mar 12 '17 at 21:33
  • @trashgod Thanks for the hint, I will have a look at it! – Markus Weninger Mar 12 '17 at 21:41
  • 2
    The JDK also ships with tools for building "Self-contained application bundles", which essentially bundle the JDK, JavaFX, and your application into a native installable app. The [deployment guide](http://docs.oracle.com/javase/8/docs/technotes/guides/deploy/) has details on how to do this. – James_D Mar 12 '17 at 22:04
  • @James_D Thank you! I found the link after I posted the question. The problem with self-contained application bundles is that you need one for every platform (e.g., "a windows build", "a ubuntu build", etc.). This blows up the whole build process. I still hope to find a way to get around that. – Markus Weninger Mar 12 '17 at 22:22
  • @MarkusWeninger how do you think about distributing your application? with an installer or just as some ZIP-file containing your jars? How about putting this "JDK needs to be installed with javafx" inside some install-instructions? – FibreFoX Mar 13 '17 at 07:49
  • Just some additional thought: the distribution/subsetting of the JDK is restricted http://www.oracle.com/technetwork/java/javase/jre-8-readme-2095710.html – FibreFoX Mar 13 '17 at 08:00
  • @FibreFoX We planned (or would prefer) to ship our application as zipped jars ("download and run"-approach). Yes, I think we will end up with a mix of install instructions and an install script for Ubuntu (which runs `sudo apt-get install openjfx`). There would also be the possibility to build an OpenJFX build (https://wiki.openjdk.java.net/display/OpenJFX/Building+OpenJFX) and to ship that one, but I think this is over the top for this project. I think we stay with install instructions+install script and hope that OpenJFX someday will be automatically installed alongside OpenJDK. – Markus Weninger Mar 13 '17 at 10:52
  • 1
    @MarkusWeninger so your approach is only valid for Linux/Ubuntu? It is possible to create an installer with `javapackager` (or javafx-maven-plugin/javafx-gradle-plugin ... I'm the maintainer/creator of them) without the bundled JRE and adjusted control-file, which is used for creating the DEB-installer. All you need is to adjust/add `Depends` for some openjfx. You might need to adjust the postinst-script too for setting the path to RUNTIME, like here: https://github.com/VocabHunter/VocabHunter/pull/17/files – FibreFoX Mar 13 '17 at 11:46
  • @FibreFoX Since most of the windows Java installations will have JavaFX installed, my main concern is Linux/Ubuntu, yes. I have to admit that I am not very experienced with installers, but I will have a look at it, thank you! Creating a DEB-installer with a dependency on `openjdk` and `openjfx` sounds like a good idea! – Markus Weninger Mar 13 '17 at 11:51

1 Answers1

1

This page (http://www.sj-vs.net/creating-a-simple-debian-deb-package-based-on-a-directory-structure/) describes very well how to build a simple .deb package based on any directory structure (e.g., with precompiled stuff). You can than add your dependencies, e.g., to javafx packages, to the Depends section of the control file. (https://www.debian.org/doc/debian-policy/ch-relationships.html). This forces any installer like apt or dpkg to install javafx together with your package and makes them fail if this package is not available. You can also add a postinst script that will be executed after the installation in which you can set classpaths etc if necessary.

loonytune
  • 1,775
  • 11
  • 22