Stefan Boos

My personal GitHub pages

Follow me on GitHub

Java

Table of Contents generated with DocToc

Documentation

Tools and Frameworks

Installing Java on Windows

One Java Version Only

Switching Between Multiple Versions of Java using SDKMAN

You can install either in a GitBaSH or into Ubuntu on WSL-2.

For GitBaSH you need MinGW-x64 and the zip (and unzip) tools. I am installing them using Chocolatey:

choco install git mingw zip

For Ubuntu in WSL-2 you need zip and unzip:

sudo apt install unzip zip

Next, install SDKMAN

Finally, install the desired java version(s):

sdk list java
...
sdk install java 17.0.7-tem

If you are using JetBrains IntelliJ IDEA, then you can add your Java SDKs via the File -> Project Structure dialog on the Project or Platform Settings/SDKs views. The base folder for the SDK is in C:\Users\yourname\.sdkman\candidates\java\17.0.7-tem (as an example for java 17 temurin).

Installing Java on macOS

One Java Version Only

On macOS I am installing java by means of Homebrew:

brew install temurin

This will download and install the latest OpenJDK provided by the Adoptium project.

For code development I am using JetBrains IntelliJ IDEA whom I wish to thank for the free license they grant to me because of my open source contributions.

Please check the list of IntelliJ IDEA Plugins I recommend.

Switching Between Multiple Versions of Java

Works For Both Java And Gradle
  1. Install sdkman

  2. Install java and gradle

    # Install latest
    sdk install java
    sdk install gradle
    
    # Install an alternative version
    sdk install java 11-ms
    sdk install gradle 6.7.1
    
  3. Select a default version for java and gradle

    sdk default java 11.0.14-ms
    sdk default gradle 6.7.1
    
  4. Use a different version of java and gradle in the current shell (restored to default in the next shell)

    sdk use java 11-ms
    sdk use gradle 6.7.1
    
Works For Java, Doesn’t Work For Gradle
  1. Install jenv

    brew install jenv
    # Remember to add the initialization code to .zshrc or .bashrc
    # Restart your shell
    
  2. Install some Java versions using Homebrew

    brew tap homebrew/cask-versions
    brew install temurin
    brew install temurin11
    
  3. Find out the Java version paths

    /usr/libexec/java_home -V
    
  4. Register the Java version paths with jenv

    jenv add ... # for each Java version you'd like to switch to
    
  5. Verify

    jenv versions
    
  6. Switch Java version (e.g. 11)

    jenv global 11
    
  7. In a specific directory, select a different Java version (e.g. 17)

    jenv local 17
    

API Services and Web Applications