--This is a procedure memo to install java using Homebrew on Mac. --I am using Sierra (10.12.2). --It is assumed that no version of java is installed at this time.
$ brew update
$ brew doctor
$ brew cask install java
$ /usr/libexec/java_home -V
Execution result
Matching Java Virtual Machines (1):
9.0.4, x86_64: "Java SE 9.0.4" /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
If bash_profile does not exist, create it.
$ touch ~/.bash_profile
Open bash_profile with an editor and add as follows. Please note that the PATH varies depending on the environment ...
export PATH=$PATH:/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
Reflect the update of bash_profile with the source command.
$ source ~/.bash_profile
Do the following and verify that you see the directory you just added.
$ echo $PATH
$ echo $JAVA_HOME
Install java8 on mac Learn the meaning of "passing the PATH" by building a Java development environment on Mac
Recommended Posts