BrightSpots / rcv

Ranked Choice Voting Universal Tabulator
Mozilla Public License 2.0
74 stars 19 forks source link

tabulator doesn't run in JDK 11 #239

Closed tarheel closed 5 years ago

tarheel commented 5 years ago

From Greg Dennis:

Hi guys,

The suggestion on rankedchoicevoting.org to use JDK 11 doesn't seem to work:

java -jar rcv_20190302.jar Error: Could not find or load main class com.rcv.Main Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

I think this is because JavaFX is available as a separate module in JDK 11. I had to jump through Oracle's hoops to download their archived JDK 10 version to run it successfully.

There is some guidance on StackOverflow on building a JavaFX app that runs on JDK 11 (and presumably continues to work with JDK 10, too). Have you looked into doing that? If that would take a longer-term effort, maybe the website instructions should be updated in the interim?

Thanks, Greg

tarheel commented 5 years ago

I've succeeded in getting the app to build and run in JDK 11 within IntelliJ, but I haven't yet figured out how to generate a functional JAR. There doesn't appear to be any simple way to do this. :(

tarheel commented 5 years ago

Upon further investigation: it looks like it's impossible to build a single cross-platform JAR for a JavaFX app in Java 11+, because you have to include native libraries in the build. So if we're going to move to 11 or higher, we'll have to start doing separate builds for Mac, Windows, and Linux. It also doesn't appear to be possible to accomplish this directly in IntelliJ.

tarheel commented 5 years ago

Alternatively, we can just ask people to install JavaFX for themselves. I'm able to make the JAR work under Java 11 with this command:

java --module-path lib/javafx-sdk-11.0.2/lib --add-modules=javafx.controls,javafx.fxml -jar out/artifacts/rcv_jar/rcv.jar

tarheel commented 5 years ago

Some possibly helpful links if we want to do something fancier: https://medium.com/@adam_carroll/java-packager-with-jdk11-31b3d620f4a8 https://medium.com/azulsystems/using-jlink-to-build-java-runtimes-for-non-modular-applications-9568c5e70ef4

moldover commented 5 years ago

Just making sure I have this right: you can make a standalone build for MacOS jdk 11 other platforms will require a platform-specific build process alternatively the end user can install JavaFX for their platform, and our current .jar should work

tarheel commented 5 years ago

I have not succeeded in making a standalone build, even for Mac. My understanding is that it is possible to do it for any platform using the corresponding JavaFX jmods, but I haven't figured out that process yet.

I did confirm that our current JAR works under JRE 11 if you download the JavaFX SDK and reference it in the command line args, as described above... at least on my Mac. Presumably it would also work on other platforms, but I don't have a convenient way to test.

HEdingfield commented 5 years ago

The answer here may be to start officially using Maven or Gradle (this comment made me realize that).

HEdingfield commented 5 years ago

And this makes me lean towards Gradle. Full docs here.

HEdingfield commented 5 years ago

Finally, here's the official JavaFX documentation on how to do this, and here's a video on how to make all this work together in IntelliJ. Happy to take on transitioning our project over to this, but I don't think it's super high priority, right?

tarheel commented 5 years ago

Sure, go for it. And I agree that this is not the top priority at the moment.

moldover commented 5 years ago

This is a great idea :) Using Gradle is also going to be helpful when we are ramping up our build and release process which is a big chunk of the VVSG requirements.

HEdingfield commented 5 years ago

Another note somewhat related to this: we should make sure we're developing with Open JDK 11+, rather than shitty Oracle JDK 11+.

HEdingfield commented 5 years ago

Explored this issue today and was able to get a basic "hello world" JavaFX Gradle project going in IntelliJ, mostly following these "JavaFX and IntelliJ => Modular with Gradle" instructions (with some bouncing over to the non-modular version on the same page when I hit walls). I used OpenJDK 12, downloaded from here.

Here are some notes on how our development workflow would change after migrating over to Gradle:

Using the IntelliJ Gradle panel

The next step is for me to get all our existing code moved over to this new format / structure.

gngilbert commented 5 years ago

I labeled this cert-del because it sounds related to the Java issue you guys have spent so much time on recently. If I am wrong, feel free to correct me.

HEdingfield commented 5 years ago

Addressed via #272. Now the tabulator only works in JDK 11+. When distributed using Gradle's distZip task, it requires that the user have the JDK installed. When distributed using Gradle's jlink task, it doesn't even require that the user have the JDK installed (the zip is 48 MB vs. 26 MB with distZip).