It has certainly been a minute since I worked with Java. With Kotlin being adopted for Android and Scala being a bit less obtuse over time, I’m not sure if plain Java is as attractive a language to start a project with nowadays.
Oh there are plenty of legacy software running on Java, to be sure. If you are working at a place with large codebases on Java, you won’t be moving off to Kotlin or Scala or Clojure any time soon. I personally still maintain a Log4j2 appender library that I started in Java many years ago.
This post is just setting things up so that I have the same JDK version on both my Windows desktop and MacBook Pro.
Java 2D/Swing -> JavaFX
I was cleaning up my bookshelves recently to part with some old books to make room for new ones. In the process I found a book I had forgotten about that talked about Java 2D and Swing. Flipping through the book got me interested in Java again. It’d be a nice respite from dealing with HTML/Javascript. A quick search on the Net to catch myself up showed that there is now JavaFX. My hope to get away from markups like HTML was dashed, however, as soon as the Scene Builder framework came up; it used FXML which to me looked enough like XML that I remembered why I moved away from the unwieldy J2EE or even the earlier Spring + Hibernate environments that lived off of gigantic XML files.
Having said that, I am still a bit interested in where things are with Java thick client nowadays and plan to spend some time with this JavaFX thing. Whether I will stay with it after my fill of Java nostalgia remains be seen.
For “backend” projects, using a Docker environment pretty much spares me the messy JDK/Java runtime upkeep on the host system (or at least funnel them all into one Linux setup). However, with UI stuff in Linux (and any Unix variant), we’re talking about X11 displays. There are resources on getting X11 to work with Docker, as well as a tool called x11docker, that may help bridge the tools. However, before I invest time in that plumbing, I want to see if I remain interested in JavaFX enough to warrant the effort. So… this means just taking the road with least resistance for now.
OpenJDK
As of the time of this writing, the latest version of OpenJDK is 25. A quick search also reveals that JavaFX 25 is available. I’m not sure if the versions need to align since I was able to get JavaFX 21 running on OpenJDK 25. But it doesn’t hurt to get the latest versions since I’m at the ideal situation of starting from scratch.
MacOS X
Installing Java has always been a hit-and-miss for me, especially when it comes to the MacOS. There are different choices that I’ve come in contact with:
- .dmg file
- .tar.gz file
- brew
Then there is this special subdirectory that is supposed to be important:/Library/Java/JavaVirtualMachines
Cleaning Up Old Versions
Running the tool /usr/libexec/java_home can also identify places where it finds additional Java versions. Although not documented anywhere, somehow I got a couple of Amazon Corretto versions installed under ~/Library/Java/JavaVirtualMachines. That’s right–the ~ is correct; they are under my home directory, not the global /Library/Java/JavaVirtualMachines.
Copilot tells me (based on some 12-year-old StackOverflow post) that:
“No — /usr/libexec/java_home does not search ~/Library/Java/JavaVirtualMachines by default.
The tool scans only system-wide installation directories:
/Library/Java/JavaVirtualMachines//System/Library/Java/JavaVirtualMachines/“
Who are you going to believe, Copilot or your eyes?
I went ahead and deleted the old ones I didn’t need anymore. In fact, I’m wiping the entire Java subdir under my home: sudo rm -rf ~/Library/Java
This cleared up the extra versions. Bonus is that I recovered some disk space, too.
Installing OpenJDK 25
Since the “current” version of OpenJDK is 25, I did a check with Brew:
brew search openjdk
==> Formulae
openjdk openjdk@11 openjdk@17 openjdk@21 openjdk@8 openj9 openjph openvdb
==> Casks
adoptopenjdk microsoft-openjdk@11 microsoft-openjdk@21 openttd
microsoft-openjdk microsoft-openjdk@17 microsoft-openjdk@25
Looks like it’s Microsoft to the rescue with microsoft-openjdk@25. Further search reveals a very useful page: https://learn.microsoft.com/en-us/java/openjdk/download
Going with Microsoft, it looks like I now have these choices:
- Install with brew.
- Download the .pkg and run it.
- Download .tar.gz and uncompress and copy the entire jdk subdir into /Library/Java/JavaVirtualMachines/.
To uninstall (ordered corresponding to the options above):
- Run
brew uninstall <version>for brew option. - Run
sudo rm -rf /Library/Java/JavaVirtualMachines/<subdir>for the .pkg and .tar.gz options. - Also run
sudo pkgutil --forget com.microsoft.<version>.jdkfor the .pkg option.
I would not have believed this for a second that Microsoft would be the one to champion Java–and on MacOS no less–better than both Oracle and Apple (R.I.P. Sun Microsystems).
Anyway. I went with the .tar.gz option:
- Downloaded
microsoft-jdk-25.0.0-macos-x64.tar.gz(into~/Downloadsby default) - Expand:
> cd ~/Downloads
> tar xzvf microsoft-jdk-25.0.0-macos-x64.tar.gz
...
x ./jdk-25+36/
x ./jdk-25+36/Contents/
x ./jdk-25+36/Contents/Home/
x ./jdk-25+36/Contents/Home/bin/
...> sudo mv jdk-25+36 /Library/Java/JavaVirtualMachines - Set up PATH in ~/.zshrc:
export JAVA_VERSION=jdk-25+36
export JAVA_HOME="/Library/Java/JavaVirtualMachines/${JAVA_VERSION}/Contents/Home"
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
And to check things are working:
> javac -version
javac 25
> java -version
openjdk version "25" 2025-09-16 LTS
OpenJDK Runtime Environment Microsoft-12398211 (build 25+36-LTS)
OpenJDK 64-Bit Server VM Microsoft-12398211 (build 25+36-LTS, mixed mode, sharing)
Windows
Installing OpenJDK 25
For Windows, these options are available (again using Microsoft’s OpenJDK site, only this time it’s natural since we’re on Windows):
- Use WinGet in Windows PowerShell (e.g.
winget search openjdkto find the ID, then usewinget install <id>). - Download the .msi file and run it.
- Download the .zip or .tar.gz file, uncompress, move it anywhere and add its bin location to the %PATH%.
To uninstall (ordered corresponding to the options above):
- Run
winget uninstall <id>. - Go to Settings > Apps > Installed apps and uninstall from there.
- Delete the subdir and remove the path from %PATH%.
JavaFX
As for JavaFX, what I’ve read so far (https://openjfx.io/openjfx-docs/#maven) leads me to believe that, as long as I add the correct dependencies in Maven’s POM, I shouldn’t need to install further stuff. However, if that ends up being incorrect, there is this page: https://gluonhq.com/products/javafx/. And if additional steps are involved, I’ll post a follow-up.