After some additional effort to figure this out, it turned out to be an easy fix. SDKman stores the JDKs in this folder:

C:\Users\yourUserName\.sdkman\candidates\java

When you issue the command

sdk default java 8.322.06.2-amzn

it copies the JDK from the java 8 folder

C:\Users\yourUserName\.sdkman\candidates\java\8.322.06.2-amzn

and pastes it into the current folder.

C:\Users\yourUserName\.sdkman\candidates\java\current

The idea is that you point your pc to the "current/" directory so that when you change java version with SDKman, the pc environment variable never needs to be updated.

But for the ide, instead of pointing it to the "current/" directory, you can point it directly to the JDK folder

C:\Users\yourUserName\.sdkman\candidates\java\8.322.06.2-amzn

You can specify the JDK for each project, P1 and P2, separately. So even if you change java version with SDKman, that only effects the "current/" directory, which the ides are no longer pointing at.

Since I did this, I dont have to change java version if I want to switch working on my java 8 project to working on my java 11 project. And that means I dont have to close my java 8 project to open my java 11 project. I can have them both open at the same time, and switch between them easily.

Answer from Steve T on Stack Overflow
🌐
SDKMAN!
sdkman.io › usage
Usage | SDKMAN! the Software Development Kit Manager
Language Specification and the Java Virtual Machine Specification. ... This will result in a list view showing the available, local, installed and current versions of the SDK. ================================================================================ ... It is important to realise that this will switch the candidate version for the current shell only. To make this change permanent, use the default command instead.
🌐
Researchlab
researchlab.github.io › 2019 › 09 › 07 › mac-upgrade-java-version
Switching between JDK 8 and 11 using SDKMAN! | 一线攻城狮
October 19, 2021 - To temporarily switch to another version, use the sdk use command. For instance, if you made JDK 8 the default, then switch to JDK 11 in the current session by typing: ... To set a permanent default, use the sdk default command. For instance, to make JDK 11 the default, type: sdk default java ...
Discussions

How do you change java version using SDKMAN without needing to close Intellij IDEA first? - Stack Overflow
I have sdkman installed on my PC laptop. I work on two separate projects, where P1 uses Java 11 and P2 uses Java 8. If I am working on P1, but something comes up and I need to work on P2, I will op... More on stackoverflow.com
🌐 stackoverflow.com
Easily switch between java versions with SDKMAN! and 'j'
Gradle and toolchain is my personal best solution. So you don't need to configure your environment on each project if you have to manage different java version. And in addition it works very well together with sdkman. More on reddit.com
🌐 r/java
41
20
December 30, 2022
Why won't sdkman change my default java version? - Stack Overflow
This problem persisted after updating and upgrading sdkman, deleting .sdkman and reinstalling it, and uninstalling java packages and reinstalling them. me@myMachine myProject $ sdk default java 8.0... More on stackoverflow.com
🌐 stackoverflow.com
Java version not swapping
Hi all. Currently trying sdkman for the first time. I'm fairly new to programming and am bouncing between projects for some courses on Coursera and some tutorials on YouTube. I've run into ... More on github.com
🌐 github.com
11
February 22, 2021
🌐
GitHub
github.com › sdkman › sdkman-cli › wiki › FAQ
FAQ · sdkman/sdkman-cli Wiki · GitHub
Run archlinux-java unset then remove all versions of Java from the default locations. Afterwards, install the desired versions with SDKMAN and use the java versions installed at $HOME/.sdkman/candidates/.
Author   sdkman
🌐
Medium
medium.com › @zorozeri › manage-java-version-using-sdkman-including-maven-gradle-scala-kotlin-and-many-more-82532be9437e
Manage Java Version using SDKMAN! (including Maven, Gradle, Scala, Kotlin… and many more!) | by Ahmad Azeri Chandra Bhuana | Medium
January 16, 2025 - If this is the first time Java is installed using SDKMAN! it will be used as the default Java. You can check it by run usual java -version command : ... Now, let’s install the second Java version. This time I’ll choose Vendor Oracle with Version 21.0.5. The command would be : ... You’ll be asked whether you want to use this new installed version as the default or not. If yes, then type Y and hit enter. ... Once you check the version, it is already changed!
Top answer
1 of 2
6

After some additional effort to figure this out, it turned out to be an easy fix. SDKman stores the JDKs in this folder:

C:\Users\yourUserName\.sdkman\candidates\java

When you issue the command

sdk default java 8.322.06.2-amzn

it copies the JDK from the java 8 folder

C:\Users\yourUserName\.sdkman\candidates\java\8.322.06.2-amzn

and pastes it into the current folder.

C:\Users\yourUserName\.sdkman\candidates\java\current

The idea is that you point your pc to the "current/" directory so that when you change java version with SDKman, the pc environment variable never needs to be updated.

But for the ide, instead of pointing it to the "current/" directory, you can point it directly to the JDK folder

C:\Users\yourUserName\.sdkman\candidates\java\8.322.06.2-amzn

You can specify the JDK for each project, P1 and P2, separately. So even if you change java version with SDKman, that only effects the "current/" directory, which the ides are no longer pointing at.

Since I did this, I dont have to change java version if I want to switch working on my java 8 project to working on my java 11 project. And that means I dont have to close my java 8 project to open my java 11 project. I can have them both open at the same time, and switch between them easily.

2 of 2
0

Inside IntelliJ versus outside IntelliJ

  • For running a project from within IntelliJ, you specify which JDK to use by configuring within IntelliJ.
  • The current default JDK set by SDKMAN! only applies to Java apps being executed on their own, outside IntelliJ.

Unfortunately, configuring which JDK to run your app within IntelliJ is complicated and confusing, requiring you to go spelunking through various buried panels.

These panels include some for the JDK, and some for the language level (which version of Java to target):

  • File | Project Structure | Project Settings | Project | SDK … and Language Level.
  • File | Project Structure | Project Settings | Project | Modules | Language Level.
  • Settings | Build, Execution, Deployment | Compiler | Java Compiler | Per-module bytecode version.

There may be others I don't recall at the moment. Search Stack Overflow to learn more.

If you are building a Web app in IntelliJ Ultimate edition, and running that app from within IntelliJ via an external application server such as Tomcat, Jetty, Glassfish, OpenLiberty, etc., then you need to also specify in another IntelliJ panel which JDK should be used to launch that app server.

If using Maven or Gradle, you need to specify language level there too.

🌐
GitHub
github.com › sb2nov › mac-setup › issues › 201
add: sdkman to manage java versions · Issue #201 · sb2nov/mac-setup
April 30, 2018 - I'm Submitting a ... [ ] Bug report [X] Tool/language/etc documentation request Tool/Language/etc Hey, I'm a Java Developer, and I use sdkman to manage Java versions (and other sdks). Do you think that is valuable add this config on Java...
Author   sb2nov
🌐
Antoniomaria
antoniomaria.github.io › development-tools › sdkman-java-installation.html
How to install SDKMan on macOS
$ cat .sdkmanrc # Enable auto-env through the sdkman_auto_env config # Add key=value pairs of SDKs to use below java=8.0.362-zulu · Active the sdk environment whenever you need to change java version for the current shell session
Find elsewhere
🌐
Wimdeblauwe
wimdeblauwe.com › blog › 2018 › 2018-09-26-switching-between-jdk-8-and-11-using-sdkman-
Switching between JDK 8 and 11 using SDKMAN - Wim Deblauwe
September 26, 2018 - And OpenJDK 11 after that with: sdk install java 11.0.0-open · During the installation, you can choose what version to make the default.
🌐
Mac Install Guide
mac.install.guide › java › sdkman
Install SDKMAN for Java on Mac · Mac Install Guide · 2026
Use sdk default to change the Java version for all new terminal sessions: $ sdk default java 25.0.1-tem setting java 25.0.1-tem as the default version for all shells. This updates the current symlink in ~/.sdkman/candidates/java/ and affects all future terminals.
🌐
SDKMAN!
sdkman.io
Home | SDKMAN! the Software Development Kit Manager
Meet SDKMAN! – your reliable companion for effortlessly managing multiple Software Development Kits on Unix systems. Imagine having different versions of SDKs and needing a stress-free way to switch between them. SDKMAN! steps in with its easy-to-use Command Line Interface (CLI) and API.
🌐
Medium
medium.com › @ajeesh2705 › use-multiple-version-of-java-6219258bd8eb
Install Multiple Versions of Java in Mac using sdkman | by Ajeesh Sasidharan | Medium
August 7, 2019 - You can opt to have different java version for each module in IntelliJ. To set sdk, go to project structure (File -> Project Structure), change sdk on project or module level as shown below.
🌐
Medium
medium.com › @annurahar › manage-various-java-versions-on-mac-osx-e6aee82c882c
Manage various Java versions on Mac OSX | by Annu Rahar | Medium
September 16, 2021 - Manage various Java versions on Mac OSX There are few options to do the installation as well as manage JDK switching. Installation can be done by Homebrew, SDKMAN, Jabba, or a manual install …
🌐
JDriven
jdriven.com › blog › 2020 › 10 › Automatic-Switching-Of-Java-Versions-With-SDKMAN
Automatic Switching Of Java Versions With SDKMAN! - JDriven Blog
October 16, 2020 - In our final example we have enabled the setting sdkman_auto_env, so when we change to the project directory the correct Java version is activated automatically: ~ $ java -version openjdk version "15" 2020-09-15 OpenJDK Runtime Environment AdoptOpenJDK (build 15+36) Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.22.0, JRE 15 Mac OS X amd64-64-Bit Compressed References 20200922_45 (JIT enabled, AOT enabled) OpenJ9 - 1830b1927 OMR - 73d5e7623 JCL - 7e7613c015 based on jdk-15+36 ~ $ cd project-dir Using java version 11.0.8.hs-adpt in this shell.
🌐
Opensource.com
opensource.com › article › 22 › 3 › manage-java-versions-sdkman
Manage Java versions with SDKMan | Opensource.com
March 15, 2022 - Instead you can type sdk install java 11 and then press Tab a few times to get the options. Alternately, you can just install the default latest version: ... You can do more customization with SDKMan, including updating and upgrading Java versions ...
🌐
GitHub
gist.github.com › drm317 › 3e2a9ce4ba1288c4fbaab1e534d71133
OpenJDK 11+ on MacOS X · GitHub
export JAVA8_HOME=$(/usr/libexec/java_home -v1.8) export JAVA9_HOME=$(/usr/libexec/java_home -v9) export JAVA10_HOME=$(/usr/libexec/java_home -v10) export JAVA11_HOME=$(/usr/libexec/java_home -v11) alias java8='export JAVA_HOME=$JAVA8_HOME' alias java9='export JAVA_HOME=$JAVA9_HOME' alias java10='export JAVA_HOME=$JAVA10_HOME' alias java11='export JAVA_HOME=$JAVA11_HOME' # Specify Java 11 as the default version java11 · The aliases can be used to change versions on the fly
🌐
GitHub
github.com › sdkman › sdkman-cli › issues › 1068
Question: Install x86 JDK on M1 Mac · Issue #1068 · sdkman/sdkman-cli
March 14, 2022 - More precisely I need nd4j and javacpp which are not available for Arm64 yet and maven tries to retrieve macosx-arm64 versions that are not available. I tried the sdkman_rosetta2_compatible switch as described here (https://itnext.io/how-to-install-x86-and-arm-jdks-on-the-mac-m1-apple-silicon-using-sdkman-872a5adc050d) but the list of available java versions is the same with switch set to true and false.
Author   sdkman
🌐
Reddit
reddit.com › r/javahelp › how do i change default version of java from my terminal?
r/javahelp on Reddit: How do I change default version of java from my terminal?
December 22, 2023 -

Currently, when I input "java -version", I get an output of "20.0.1". When I input "/usr/libexec/java_home -V", It says I have 20.0.1, 17.0.9, and 11.0.9.
When I input "export JAVA_HOME=$(/usr/libexec/java_home -v 17.0.9);" to change the version and run "java -version" again, It shows as 17.0.9.
The problem is when I close my terminal and check my java version, it returns back to version 20. How do I permanently change my default java version. Thanks.