Upgrading a Gradle JavaFX Application

I'm helping out a bit with an IntelliJ IDEA Live Stream on JavaFX, and I used that as an excuse to refresh my JavaFX knowledge. One of the things I did was make sure I upgraded all my existing applications to the latest versions of everything and make sure they work as expected.

I have what is now quite an old demo application, originally designed to showcase Java 8 features (watch the live demo and find out more). Since JavaFX was moved into the JDK in Java 8, I decided to use JavaFX as the UI. In fact, it's this demo that was the basis for all my later JavaFX applications, including the Spring Boot one.

I haven't done much with this for a loooong time, but it turns out I have been periodically updating dependencies and trying to make sure it all compiles. I highly recommend taking the time to do this at least once a year! It turns out that because I've been updating dependencies for the last 3-4 years that it wasn't that painful to bring it right up to date. In fact, I did it in less than 30 minutes!

Steps

  1. Upgraded to latest version of Gradle (6.8). When you do this, you want to make sure that not only do you do a full, clean rebuild from the command line, but you also want to reload the Gradle settings for IntelliJ IDEA and do a full rebuild inside the IDE.
  2. I had to change the way some file access was done. I've been fiddling with this for a few versions now, I think it's because resource files are loaded differently since Java 9? or 11? and also I think IntelliJ IDEA loads resource files differently. So I opted to simplify what I was doing there.
  3. Updated versions of all dependencies in all my back end services to whatever is the most recent version.
  4. Updated my JavaFX Gradle plugin to 0.0.9. Apparently I was smart enough to start using the JavaFX plugin in early 2020, when I also upgraded the project to Gradle 6.3 and Java 11.

That was it, it worked!

Running the Application

Runs only from Gradle.

This application runs from the command line (or IntelliJ IDEA terminal window) with:

./gradlew dashboard:run

or you can run it from the IntelliJ IDEA Gradle tool window

or from "Run Anything" (Ctrl Ctrl)

What you can't do is use the green arrow gutter icons, or the run shortcuts (Ctrl Shift R or Ctrl Shift F10) inside Dashboard.java in IntelliJ IDEA. It's not the end of the world, because you can use any of the above, but it's a bit confusing.

Resources

See also:

Author

  • Trisha Gee

    Trisha is a software engineer, Java Champion and author. Trisha has developed Java applications for finance, manufacturing and non-profit organisations, and she's a lead developer advocate at Gradle.

    View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.