On Oracle, Java 11 & macOS 10.14

So the current news of the day is that Oracle has halted free commercial use of Oracle Java.  They provide OpenJDK that can be used for commercial purposes without a fee, but with little support.   This blog is the most clear write up on the subject.

Note, if you don’t understand the implications of doing the following, don’t try.

Once we declare Oracle to be evil, time to purge macOS of all evil. First, get rid of all JDKs.

sudo rm -rf /Library/Java/JavaVirtualMachines/jdk*.jdk

Remove Plugins

sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/LaunchAgents/com.oracle.java.Java-Updater.plist
sudo rm -rf /Library/PrivilegedHelperTools/com.oracle.java.JavaUpdateHelper
sudo rm -rf /Library/LaunchDaemons/com.oracle.java.Helper-Tool.plist
sudo rm -rf /Library/Preferences/com.oracle.java.Helper-Tool.plist

Thanks to this StackOverflow post for the steps above. 

Next download AdoptOpenJDK for macOS.  I chose JDK11 with Eclipse Open9 JVM instead of Hotspot.  If we want to purge, go all the way…

Install the JDK in a reasonably isolated location.  If you use HomeBrew then choose /opt.  If you use MacPorts, then choose /usr/local.  This will avoid confusing the package manager.  Add the PATH modification to your shell (I hope that people have moved from bash to zsh by now).  Also, set the JAVA_HOME environment variable.   This will help tools like maven work. 

export JAVA_HOME=/opt/jdk-11.0.1+13/Contents/Home/

Now comes the fun part of deprecated J2EE classes, etc. for which you now need to have external dependencies in your project that satisfy these.  Refer to this StackOverflow post to get started.