Issues with Java11/JavaFX11 modules

Hey guys, I posted an issue on StackOverflow yesterday and haven’t be able to get any substantial help on it. I figured I’d post the problem here and see if I could get any help from you guys:

Sorry in advance if there’s some kind of obvious answer to the problem, I’m just genuinely new to Java11. Personally I think the whole moduling thing is overcomplicated for no real good reason but that’s just me. If you guys could upvote the question I’d also appreciate that so more people will take a look at the question.

There is a lot being asked in your stackoverflow question. It’s not the easiest thing for me to untangle. But I thought I could maybe put in a couple helpful points.

If your program has javafx, the command

java -jar yourprogram.jar

won’t work. You have to include a path to the JavaFX modules.

OpenJDX.io has a good tutorial. This page (subpage: Runtime Images/Modular with CLI) has the syntax.

One thing that threw me at first when I started using OpenJDK 11 with OpenJFX 11, is that the code needs to be able to reach both the javafx.jar files and the javafx modules. Thus, you have to install BOTH the JDK and the jmods from Gluon’s JavaFX download page.

With Eclipse, to develop and be able to run a program with JavaFX, I had to include the SDK files in the Build Path/Libraries/Modulepath. (It is sitting adjacent to the JRE System Library – now OpenJDK 11.)

Also, I have to have the following in Run Configurations/Arguments/VM arguments:

--module-path "c:\Program Files\Java\javafx-jmods-11.0.1" --add-modules=javafx.controls

This is covered in the openjdk.io “Getting Started” tutorial subsection on Eclipse.

I have never used “Export/Java/Runnable JAR file” but have always used “Export/Java/JAR file”, so I can’t help with that.

In fact, at this point, I just export source code and do command-line compiling and jlinking, along a slightly modified version of this tutorial. For Windows, I use InnoSetup5 for the last stage of packaging.

For the Mac, I’m still working out the details of packaging. I got JLINK to work and can run applications on the Mac, but am still trying to get my brain around the steps where one turns the file folder into an .app. I posted earlier today on StackOverflow asking for some help to connect the dots on this.

That command actually DOES work if you use it just like that since it’s a runnable jar. You can also run the jar by just clicking it. The problem is when you try and use the java command from a specific JRE path for some reason.

As for the module path, I’ve tried that, but it only appears to work if you give it an explicit path. That’s not so easy to do if you’re running the software on someone elses computer. You’d also have to expect them to have installed it in the same place as you. (Unless you mean setting this up before exporting the JAR - I already do this in Eclipse to make the Runnable JAR, so that’s not an issue here. The issue is that despite this, Java is saying I didn’t include JavaFX when I try and run the program in my own way).

Regardless, I’ll check out those resources and let people know if I can get it working.

Edit: I reformatted the Stack question to make it easier to read.

Edit 2: The reason why the default jar command was working for me was because my computer was defaulting to Java10. Going to keep looking into the issue.

[quote]As for the module path, I’ve tried that, but it only appears to work if you give it an explicit path. That’s not so easy to do if you’re running the software on someone elses computer. You’d also have to expect them to have installed it in the same place as you.
[/quote]
Yes. I kind of gave up hope of realistically being able to distribute Java programs using JavaFX by the old method of distributing a jar, for exactly the reasons you list. Maybe it will be possible to run executable jars if only Swing is used, going forward. But I’m not counting on that, either, especially if there are new complications, like the user having to figure out where to load Java from if Oracle is going to start charging a fee for Java.

That’s why I’m trying to solve for customized, self-contained apps. The Win64 task list is pretty easy, now that I have the command-line commands stored for easy copy/paste into the shell. Can build a distributable in about 3 or 4 minutes, using less than a half-dozen commands. I’m still working on getting the Mac jlink file folder build configured as an .app. This post gives me hope that it won’t require dealing with Bundles and Info.plist files to do so. Looking forward to some free time later this week to give it a try.

Maybe it helps, it needs some small changes to work as is with Java 11:
http://tuer.sourceforge.net/en/documentation/#create-os-x-app-bundle
https://svn.code.sf.net/p/tuer/code/pre_beta/src/main/xml/jndt/antlib.xml