Skip to main content

Setting up JDKs using SDKMAN

Build tool requirements for Pulsar master branch​

Building the Pulsar master branch requires JDK 21, JDK 25, or JDK 26 (server bytecode targets Java 21; client and public API bytecode targets Java 17). There is no separate build tool to install: Pulsar uses a Gradle build (migrated from Maven via PIP-463), and the repository includes the Gradle Wrapper — use ./gradlew. On Windows, developing inside WSL2 is strongly recommended (see Setup and building), where the Linux instructions apply as-is.

The instructions below cover installing and managing JDK versions with SDKMAN.

note

Maintenance branches (branch-4.2 and earlier) continue to use the Maven build. When releasing those versions, follow the Maven release prerequisites. Install additional JDK versions with SDKMAN as needed (for example, sdk i java 17.0.19-amzn for branches that build with JDK 17). The main branch uses Gradle and the current release process.

Setting up JDKs using SDKMAN​

Install SDKMAN​

See https://sdkman.io/install for detailed instructions.

Install a JDK​

In Pulsar development, we use Amazon Corretto OpenJDK to build Pulsar.

  • JDK 21, 25, or 26 is required for building the Pulsar master branch
    • server implementations compile to Java 21 bytecode; client libraries, client CLI tools, and public Functions/IO interfaces retain Java 17 compatibility
    • Pulsar Docker images run Java 25

Installing Amazon Corretto OpenJDK using SDKMAN​

# find out most recent Amazon Corretto release
sdk l java |grep amzn
# install Java 21
sdk i java 21.0.11-amzn
# install Java 25
sdk i java 25.0.3-amzn
# install Java 17, optional step, not needed for master branch development
sdk i java 17.0.19-amzn
# adding / updating aliases
cd ~/.sdkman/candidates/java
rm -f 17 && ln -s 17.0.19-amzn 17 # optional step, not needed for master branch development
rm -f 21 && ln -s 21.0.11-amzn 21
rm -f 25 && ln -s 25.0.3-amzn 25
# switching between versions using aliases
sdk u java 17
sdk u java 21
sdk u java 25

Setting up Java version auto-switching with SDKMAN (optional)​

With auto-switching, when there's a .sdkmanrc file in a directory, SDKMAN will switch to the defined Java version. This is convenient for developers to switch between different versions of Java.

# enable sdkman_auto_env
echo sdkman_auto_env=true >> ~/.sdkman/etc/config
# ignore .sdkmanrc files by default
echo .sdkmanrc >> ~/.gitignore_global
# enable the global ~/.gitignore_global file
git config --global core.excludesfile $HOME/.gitignore_global

# now you can add .sdkmanrc files to repository directories for automatically switching the JDK version
echo java=21 > .sdkmanrc && cd $PWD

Gradle command-line completion (optional)​

For a better developer experience, install Gradle command-line completion (gradle-completion installation instructions) for bash and zsh shells.