Sitemap
kkrajpurohit

kkrajpurohit

Hi, I'm K.K Rajpurohit, I love building utilities aimed at increasing Developer productivity .

Install JDK multiple version Apple Silicon chip (M1/M2)

1 min readJul 16, 2023

To install multiple JDK versions on a Mac, you can follow these steps on Terminal:

Prerequisite: must have already installed Homebrew .

This command will download repository for open jdk
$ brew tap adoptopenjdk/openjdk

Installing jdk 11 and 8
$ brew install — cask adoptopenjdk11 adoptopenjdk8

Installtion running command in terminal if asking during instllation of jdk8 and jdk11
$ softwareupdate — install-rosetta

Download utility jenv
$ brew install jenv

add these two commands in zshrc
$ echo ‘export PATH=”$HOME/.jenv/bin:$PATH”’ >> ~/.zshrc
$ echo ‘eval “$(jenv init -)”’ >> ~/.zshrc

add our java to jenv
$ jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home

Get kkrajpurohit’s stories in your inbox

Join Medium for free to get updates from this writer.

$ jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

Now check versions
$ jenv versions

To set java versions we can use:-

$ jenv local 1.8
$ java -version

$ jenv local 11
$ java -version

To enable java to maven
$ jenv enable-plugin maven

$ jenv enable-plugin export

$ echo $JAVA_HOME

Note :- In case if you see changes are not reflecting, Please do restart your terminal.

--

--

kkrajpurohit
kkrajpurohit

Written by kkrajpurohit

0 followers

Hi, I'm K.K Rajpurohit, I love building utilities aimed at increasing Developer productivity .