Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For macOS, Linux, and Windows users working inside WSL2, SDKMAN is the most direct way to install and manage multiple JDKs from a Linux-style shell. It works on macOS and Linux and runs on Windows through WSL—not as a native Windows tool. For native Windows applications, install a Windows JDK and configure Windows JAVA_HOME and Path separately. If you already install JDKs another way and want per-project version selection, jEnv is an alternative that registers and selects JDKs but does not install them.

Choose the environment where your Java build will run

Start by deciding whether the project uses Linux tools or Windows-native tools. If its build and deployment workflow is Linux-based, run the shell, JDK, and build tools inside your WSL2 distribution. This keeps their paths and environment settings together. Microsoft describes WSL as useful for Linux-specific build tooling and for teams seeking Linux/macOS parity; see its OpenJDK setup guide.

If you build with Windows-native tools, configure a native Windows JDK instead. A JAVA_HOME set in a WSL shell does not configure Windows applications: WSL and Windows have separate environments, JDK installations, and path conventions.

Compare the ways to switch JDKs

Approach Installs JDKs? Selection Where it fits
SDKMAN Yes; it can install Java and other SDK candidates. Shell workflow, with selection options described in its usage documentation. macOS, Linux, and Windows through WSL; not native Windows.
jEnv No; register JDKs installed separately. Global, project-local via .java-version, or current shell. Useful when you want project selection and manage installations elsewhere.
macOS java_home No. Select a JDK by version for a command or to set JAVA_HOME. macOS only.
Windows environment variables No. Set JAVA_HOME and add its bin directory to Path; the first matching executable in Path wins. Native Windows.

For a single workflow across macOS, Linux, and WSL2, start with SDKMAN. Choose jEnv if installations are handled by a package manager or vendor installer and you want jEnv to select among them, including through a project file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install and use SDKMAN on macOS, Linux, or WSL2

SDKMAN supports macOS and Linux shells and Windows through WSL. Its installation instructions require a Bash environment and tell Windows users to install WSL first; native Windows installation is not supported. Follow the current setup steps in the SDKMAN installation guide, initialize SDKMAN in your shell as instructed, then check that it responds with sdk version.

Install a Java candidate

  1. Run sdk list java to see the candidate identifiers currently available.
  2. Choose a listed identifier and install it with sdk install java <candidate>. The usage documentation also demonstrates sdk install java for installing the latest stable Java candidate.
  3. Use sdk home java <version> to display the absolute path of an installed version.

Candidate names and releases can change, so use the identifier shown by the live list rather than relying on an old example. Some commands need network access; sdk update refreshes candidate metadata. See the SDKMAN usage guide for the current commands and the distinction between changing a shell selection, choosing a default, and configuring automatic environment behavior. Do not assume automatic project switching is enabled unless you have configured it.

Use jEnv when JDKs are installed separately

jEnv is a selector, not an installer: its documentation explicitly says it does not install Java. Install each JDK with your preferred package manager or vendor installer, then register its JDK home using jenv add <JDK-home>. The documented selection priority is shell over local over global. The jEnv documentation covers installation and configuration.

Set a global, project, or shell version

  • jenv global <version> sets the default version for your user environment.
  • From a project directory, jenv local <version> selects a version for that project and creates a .java-version file. Commit the file if you want to share the selection with collaborators.
  • jenv shell <version> sets a temporary choice for the current shell; it takes precedence over local and global selections.

If a build tool or other dependent program reads JAVA_HOME or JDK_HOME, enable jEnv’s export plugin so those variables reflect the selected JDK. On macOS, the jEnv documentation shows how to register Homebrew JDKs, but paths vary by architecture and installation; do not treat an example symlink path as universal.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Select a JDK manually on macOS

macOS can have multiple JDKs installed. Oracle documents using /usr/libexec/java_home to locate a matching installation. For example, this command runs the compiler from JDK 26:

/usr/libexec/java_home -v 26 --exec javac -version

To set a shell’s JAVA_HOME to a matching installed JDK, use the same version selector:

export JAVA_HOME=$(/usr/libexec/java_home -v 26)

Check the default Java version with java -version. Oracle’s JDK 26 macOS installer replaces an existing installation of the same feature release when installing another update. That installer-specific behavior does not limit macOS to one JDK overall. See Oracle’s JDK 26 installation instructions for macOS.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Configure a native Windows JDK

For Windows-native development, install a Windows JDK—for example, Microsoft Build of OpenJDK or Eclipse Temurin using winget—then set JAVA_HOME to the JDK installation directory and add %JAVA_HOME%bin to the Windows Path. Microsoft’s OpenJDK setup guide describes installation and environment-variable setup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When multiple JDK bin directories appear in Path, Windows uses the first matching executable. Make sure the intended JDK is the one that appears first. Open a new terminal after changing environment variables, then verify with java -version and javac -version.

Verify the JDK in the environment that runs the build

Run checks in the same terminal or environment used by the build—not in a different WSL distribution, a separate Windows terminal, or another shell with different startup settings.

  • Run java -version and javac -version to check the runtime and compiler.
  • Inspect JAVA_HOME and confirm it points to the intended JDK home, especially if your build tool uses that variable.
  • If the version is unexpected, check which executable resolves first: use which java in a Unix shell or where java in Windows Command Prompt.
  • After editing a shell startup file, reopen the shell or reload its configuration, then repeat the checks.
  • With jEnv, confirm that the project’s .java-version is in the project root and that the export plugin is enabled if the build needs JAVA_HOME.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.