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

One Trackback/Pingback
  1. GraalVM on macOS – info.michael-simons.eu on March 27, 2019 at 11:40 AM

    […] fix is easy and I described it already for JDK 9 ea years […]

Post a Comment

Your email is never published. We need your name and email address only for verifying a legitimate comment. For more information, a copy of your saved data or a request to delete any data under this address, please send a short notice to michael@simons.ac from the address you used to comment on this entry.
By entering and submitting a comment, wether with or without name or email address, you'll agree that all data you have entered including your IP address will be checked and stored for a limited time by Automattic Inc., 60 29th Street #343, San Francisco, CA 94110-4929, USA. only for the purpose of avoiding spam. You can deny further storage of your data by sending an email to support@wordpress.com, with subject “Deletion of Data stored by Akismet”.
Required fields are marked *