Skip to content

JDK (Java Development Kit)

Install

Install Java using SDKMAN with the following command:

sdk install java 21.0.2-tem

Usage

Version listing

To list all available Java versions, use:

sdk list java

To list all installed and local Java versions, use:

sdk list java | awk 'NR<=5 || tolower($0) ~ /installed|local only/'

Info

The above command lists the first 5 lines of the output from sdk list java and then filters the remaining lines to show only those that contain "installed" or "local only", ignoring case. This way, you can see the available versions as well as the ones you have installed or are available locally.

Version switching

To use a specific Java version, use:

sdk use java 21.0.2-tem

To set a specific Java version as the default, use:

sdk default java 21.0.2-tem

Configure rc files

To configure SDKMAN to use a specific Java version by default, add the following line to your project's ~/.sdkmanrc file:

~/.sdkmanrc
touch ~/.sdkmanrc
echo "java=21.0.2-tem" >> ~/.sdkmanrc

You can then use the following command to apply the configuration:

sdk env

As there could be multiple versions of Java installed, you can create a symbolic link to the desired version. For example, to create a symbolic link for Java 21.0.2-tem, use the following command:

ln -sfn ~/.sdkman/candidates/java/21.0.2-tem 21-tem

Configuration

Certificates

To list the certificates in the keystore, use the following command:

keytool -list -keystore [keystore] -storepass [storepass]

To add a certificate to the keystore, use the following command:

keytool -import -alias [alias] -keystore [keystore] \ 
        -storepass [storepass] -file [certificate]