Crash Course In Java Brain Surgery

insinuation and speculations: My thoughts about Java, HTML5, software development and IT in general

Set JDK on OSX

Written by  Viktor Gamov -
terminal java
Table 1. Revisions history
Version Date Comments



Explained JVMPlatformVersion for Java 9



Added Java 9 command



Initial blog post

Apple announced to remove Java Preferences app from Mac OS X.
Details could be found here Let’s try to fix it.

Generally, Java applications will use the JAVA_HOME environment variable to pick a JDK.

To set to JDK 6
export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)
To set JDK 7
 export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
To set JDK 8
 export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
To set JDK 9
 export JAVA_HOME=$(/usr/libexec/java_home -v 9)
In JDK 9, Oracle changed JVMPlatformVersion format. Before JDK 9, the format was 1.x
info.plist jdk8 9
Figure 1. You can check this in /Library/Java/JavaVirtualMachines/{java version}/Contents/Info.plist
Created aliases for my zsh shell
alias setjdk16='export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)'
alias setjdk17='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)'
alias setjdk18='export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)'
alias setjdk19='export JAVA_HOME=$(/usr/libexec/java_home -v 9)'

For the exotic cases, like Netbeans follow instruction here