Guide: Setting Up and Switching between Java 11 and 17 on macOS

<p>This post describes how to set up OpenJDK 11 and OpenJDK 17 on macOS, and it also provides a solution for switching between these two versions.</p> <blockquote> <p>Table of Content<br /> Step 1: Install OpenJDK 11<br /> Step 2: Install OpenJDK 17<br /> Step 3: jenv &mdash; Make Switching between Java 11 and 17 possible</p> </blockquote> <h1>Step 1: Install OpenJDK 11</h1> <p>As i mentioned in the&nbsp;<a href="https://medium.com/java-mvp/3-steps-to-install-openjdk-11-on-macos-3ae0e10dfa1a" rel="noopener">previous post</a>, OpenJDK 11 can be installed on macOS by using following command.</p> <pre> sudo rm -fr /Users/yourUserName/Library/Java/JavaVirtualMachines/* sudo rm -fr /Library/Java/JavaVirtualMachines/* /bin/bash -c &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&quot; brew install openjdk@11 sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk java -version</pre> <h1>Step 2: Install OpenJDK 17</h1> <p>After OpenJDK 11 was installed from last step, we can install OpenJDK 17 now.</p> <p><a href="https://medium.com/java-mvp/guide-setting-up-and-switching-between-java-11-and-17-on-macos-9caff4c96e2d"><strong>Learn More</strong></a></p>
Tags: macOS