How to install multiple Java versions?

The version of Java installed with Android Studio on my Mac is the following (when I run java -version)

openjdk version "1.8.0_242-release"
OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
OpenJDK 64-Bit Server VM (build 25.242-b3-6915495, mixed mode)

An hour later I’m taking an online class and one of the prerequisites is OpenJDK 11.
How do I install both of the versions side by side on my Mac if I don’t have ASDF.

1 Like

Corresponding tweet for this thread:

Share link for this tweet.

As I’m using IntelliJ IDEA and while creating a new project one can choose which version of Java they wanna use, so the problem is solved.
I’m not a regular user of Jetbrains tools and often use only code editors, so I didn’t know that I can choose a Java version during the project creation step.

1 Like

I was going to ping @finner to see if he could help but looks like you sorted it :nerd_face:

1 Like

Yes. Thank you! :slight_smile:

1 Like

hi @DevotionGeo - I now use sdkman to switch through my Java versions.
Here is the usage page.
On a mac the java sdks will be installed :

/Users/<you>/.sdkman/candidates/java/

In my case I have the following

/Users/<user>/.sdkman/candidates/java/11.0.2-open
/Users/<user>/.sdkman/candidates/java/12.0.2.j9-adpt
/Users/<user>/.sdkman/candidates/java/15.0.2.j9-adpt
current -> /Users/<user>/.sdkman/candidates/java/11.0.2-open

current is a symbolic link which points to the version you are currently using, so from inside an IDE you would have to point to the real folder.

Not sure of that helps you at this stage.

2 Likes

Thank you so much @finner!

Do you recommend using asdf for managing Java versions on Mac ?

1 Like

hi @DevotionGeo - I’ve never even heard of asdf before :blush:
From what I can see about asdf it manages multiple languages, if you are constantly switching between languages and then versions within those languages then maybe asdf will work well for you. But as I’ve said, I have never used it.
If you do decide to use it let me know what you think.

2 Likes

Actually I’ve used asdf before in Ubuntu, and I’ve liked it. But once when I was trying to make Quarkus work with an asdf installed Java, I failed to make it work. Now I realize that I had installed a version other than the Hotspot Java which is recommended by Quarkus.

1 Like

I’ve previously used jenv for handling multiple versions of Java (for use with JRuby), but if you’re already using asdf I think you should just continue with that and not introduce yet another new tools.

2 Likes

yes I would agree with @ohm - mixing tools will get very confusing. I’ve never heard of jenv either. :smiley:

2 Likes