JDK 9 EA on macOS

Prevent JDK 9 early-access build to be the default JDK
August 2, 2017 by Michael

The release date for Java 9 is getting closer and it’s about time to get your hands dirty with the early-access builds. Those are available here.

I’m on a Mac running the latest version of macOS. It’s easy to change $JAVA_HOME in a shell through the various settings of you preferred environment. Sadly, $JAVA_HOME (or any other environmental variable, even it’s from a login shell) isn’t picked up by macOS for quite some time now.

So when I run /usr/libexec/java_home -V it gives me

    9, x86_64:	"Java SE 9"	/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
    1.8.0_131, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
    1.7.0_79, x86_64:	"Java SE 7"	/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home

and it picks the latest, which is 9. Several things break with this setting at the moment, for example NetBeans 8.2 doesn’t work.

There’s however a simple solution to the problem. Goto /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/ (i.e. in a terminal or even in finder) and move Info.plist to something else, like Info.plist.bak. The JDK is still fully functional and you can manually set $JAVA_HOME or configure your IDE to use it, but it won’t be picked up by the libexec-tool anymore.

No comments yet

Post a Comment

Your email is never published nor shared. Required fields are marked *