Install JDK11(MACOS)

奕伟 蒋 - Jun 17 - - Dev Community

1.download installation package

(macOS version end with .pkg)
download link

2.install jdk11

  1. open the '.pkg' file
  2. follow the installation prompts to install

3.configuring environment vaiables

  • open the terminal, run the fllowing command to confirm the installation path
/usr/libexec/java_home -v 11
Enter fullscreen mode Exit fullscreen mode
  • edit '~/.zshrc' or '~/.bash_profile' file,add the following content
export JAVA_HOME=$(/usr/libexec/java_home -v 11)
export PATH=$JAVA_HOME/bin:$PATH
Enter fullscreen mode Exit fullscreen mode
  • save and exit the file, use the following command to make the configuration effective
source ~/.zshrc
or
source ~/.bash_profile
Enter fullscreen mode Exit fullscreen mode

4.verify

  • check 'JAVA_HOME' variable
echo $JAVA_HOME
Enter fullscreen mode Exit fullscreen mode
  • check java version
java -version
Enter fullscreen mode Exit fullscreen mode
  • check javac version
javac -version
Enter fullscreen mode Exit fullscreen mode

Image description

.