Sdkman is a useful tool for Java developer which I use for quite a long time. Here I list something I just know about it.
1. Add JDK manually
By default you can use the “sdk install java
1 | # 1. Download the JDK pacakge file and extract to a directory, such as "sdk-special-version". |
2. Some useful Sdkman commands
From here.
1 | # 1. Show the current version numbers of all the working software managed by Sdkman: |
3. “.sdkmanrc”
In some cases you want to set different software versions for different projects, such as JDK 8 for project A and JDK 11 for project B. It’s doable that using Sdkman command to do the switch every time, but it’s not efficient. For such scenario, “.sdkmanrc” can be used. Get into your project directory and run the following command, which will create a “.sdkmanrc” file in the directory:
1 | sdk env init |
You can open the file, and set the software versions in it, such as:
1 | # Enable auto-env through the sdkman_auto_env config |
Every time you get in this directory, you can run the “sdk env” command to make the configuration take effect. The software versions will be set as the ones in the “.sdkmanrc” file.