Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tabulator doesn't run in JDK 11 #239

Closed
tarheel opened this issue Mar 27, 2019 · 15 comments
Closed

tabulator doesn't run in JDK 11 #239

tarheel opened this issue Mar 27, 2019 · 15 comments

Comments

@tarheel
Copy link
Contributor

tarheel commented Mar 27, 2019

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
Copy link
Contributor Author

tarheel commented May 4, 2019

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
Copy link
Contributor Author

tarheel commented May 5, 2019

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
Copy link
Contributor Author

tarheel commented May 5, 2019

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
Copy link
Contributor Author

tarheel commented May 5, 2019

@moldover
Copy link
Contributor

moldover commented May 5, 2019

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
Copy link
Contributor Author

tarheel commented May 5, 2019

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
Copy link
Contributor

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

@HEdingfield
Copy link
Contributor

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

@HEdingfield
Copy link
Contributor

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?

@HEdingfield HEdingfield self-assigned this May 7, 2019
@tarheel
Copy link
Contributor Author

tarheel commented May 8, 2019

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

@moldover
Copy link
Contributor

moldover commented May 8, 2019

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
Copy link
Contributor

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

@HEdingfield
Copy link
Contributor

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

  • Build:
    Tasks => build => build

  • Run:
    Tasks => application => run

  • Unit tests:
    Tasks => verification => test

  • Distribute:
    ** zip (standard, but probably requires more work by user): Tasks => distribution => distZip
    These two options require the "Badass JLink Plugin". Here's a great StackOverflow answer that outlines most of this stuff.
    ** jlink image (using the targetPlatform parameter, we can create images for Linux, Windows, etc. that don't even require the user to have the JRE installed!): Tasks => build => jlink or jlinkZip
    ** jpackage installer (needs configuration, and may require JDK 13, but theoretically produces native .msi, .dmg, .deb files for different platforms): Tasks => build => jpackage

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

@gngilbert
Copy link
Collaborator

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
Copy link
Contributor

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants