mechanicker icon

Installing OpenJDK11 on Mac

mechanicker | PRO | 07/01/20 12:54:47 AM UTC | 0 ⭐ | 1536 👁️ | Never ⏰ | []
Bash |

1.1 KB

|

None

|

0 👍

/

0 👎

# Every line with '#' is a comment, do not run. Run only commands that do not start with '#'
 
# Install homebrew to install and manage software on Mac
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
 
# Update and install all default software before installing Java
brew update
brew upgrade
 
# Let us install OpenJDK - tell brew the location
brew tap AdoptOpenJDK/openjdk
 
# Install OpenJDK11
brew cask install adoptopenjdk11
 
# Let us install an easy tool to manage different Java versions
brew install jenv
 
# Register OpenJDK11 in jenv
jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
 
# Check if everything works
jenv shell 11
 
# Set JAVA_HOME in shell
export JAVA_HOME=$(dirname $(dirname $(jenv which javac)))
 
# Print JAVA_HOME
echo $JAVA_HOME
 
# Check the Java version
java --version
# openjdk 11.0.7 2020-04-14
# OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
# OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)
 
# Check Java compiler version
javac --version
# javac 11.0.7

Comments