Installing Java 1.8.0 on macOS
Information
none
Operating system used
macOS (Sierra) 10.12.3
Software prerequisites
Homebrew
Procedure
- To install Java, type: brew cask install java
- To check if Java is installed correctly, open a terminal and type: java -version
You should see:
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
- Show all java versions installed.
Type: /usr/libexec/java_home -V
You should see:
1.8.0_121, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
More information about the java_home tool.
Type: /usr/libexec/java_home -help
- To use a particular java version installed.
Add the following line in your .bash_profile file.
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
If you have only one version installed, then you can omit the version:
export JAVA_HOME="$(/usr/libexec/java_home)"
If you have multiple versions installed, for example (these versions does not exists!):
1.8.3_111
1.8.4_222
and you want to use version 1.8.3_111 then you need to be more specific when specifying the version:
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8.3)"
- To check the JAVA_HOME path.
Type: echo $JAVA_HOME
|