Change JDK and JRE in Eclipse for Mac OS

Updated:

Install / check the path of JRE and JDK on your Mac

This part is optional but many developers asked for this information.

You can install the JDK on MacOS with the following tools:

With SDKMan you can install multiple versions of the JDK from multiple providers (Oracle, Amazon Corretto, OpenJDK, Microsoft OpenJDK etc.).

To install the latest Eclipse Temurin: sdk install java , to install the preview of the SDK 18, e.g. : sdk install java 18.ea.27-open

SDKMan stores the JDKs in the path: /Users/[user]/.sdkman/candidates/java and the current: /Users/[user]/.sdkman/candidates/java/current

SDKMan should set your JAVA_HOME variable to the selected version too.

Brew is ‘de facto’ package manager for MacOS, with Brew you can install the latest version of the Oracle JDK.

  • Download directly from the Vendor / Provider

Another option is to download directly from the JDK provider: Adoptium Eclipse Temurin (previously AdoptOpenJDK), Oracle JDK, Amazon Corretto etc.

Eclipse Temurin will install the JDK in the following path: /Library/Java/JavaVirtualMachines/temurin-<version>.<jdk|jre> example /Library/Java/JavaVirtualMachines/temurin-17.jdk

Oracle JDK will install the JDK in the following path: /Library/Java/JavaVirtualMachines/jdk-17.interim.update.patch.jdk

Set the JDK in Eclipse during the installation

eclipse JRE path

When you install Eclipse you can select the path of the SDK that you installed in the previous chapter. If you click on the folder Eclipse will suggest some JDK and JRE installed on your system. It won’t suggest the JDK installed with SDKMan, you can choose these manually using Browse

eclipse JRE and JDK paths

Change the JDK in Eclipse

Sometimes it happens that we have to change or add the JDK/JRE version used by eclipse and/or we want to access the correct source code of the JDK.

Here the step-by-step procedure under Mac OS X:

  1. In the menu click Eclipse -> Preferences
eclipse preferences menu
  1. Search for the Installed JRE (currently the Eclipse Temurin 17) and click ‘Add…’
eclipse installed JRE menu
  1. Add… and select the JRE or JDK Home path

In my case I want to use the preview of Java 18 installed with SDKMan, I select the path of this JDK

add the jre to eclipse

To access the sources select src.zip in the JRE System Libraries and click Source Attachment …

eclipse attach the sources of the jdk

The change is effective only for the new projects, if you want to change the JDK/JRE for an existing project:

  1. Click with the right button on the project and choose ‘Properties’. Search for ‘Java Build Path’ and select the JRE under Libraries. Click the ‘Edit’ button.
  2. Choose the new JRE
  3. (Optional) Restart Eclipse

Without a restarting if you try to call the JRE sources Eclipse will throw an error


Fullstack Angular / Java application quick start guide.
WebApp built by Marco using SpringBoot 3.2.4 and Java 21. Hosted in Switzerland (GE8).