Java Setup

Java Setup

The Apex Language Server, shipped as part of the Salesforce Apex Extension for VS Code depends upon the Java Platform, Standard Edition Development Kit (JDK). It requires an installation of either JDK version 11 (Recommended) or JDK version 8. By default, the extension attempts to locate your local Java installation by looking for a JAVA_HOME or JDK_HOME environment variable on your computer. If the extension cannot find your Java installation, or if you want it to use a different installation, change the salesforcedx-vscode-apex.java.home setting.

  1. Select File > Preferences > Settings (Windows or Linux) or Code > Preferences > Settings (macOS).
  2. Search for apex.
  3. Change the salesforcedx-vscode-apex.java.home setting to the full pathname of your Java Runtime. Do not set it to the Java executable itself.

Apex Java Setting

Below you will find instructions on how to download and configure different versions of Java.

AdoptOpenJDK

AdoptOpenJDK provides prebuilt OpenJDK binaries for free without authentication or complications.

  1. Navigate to AdoptOpenJDK
  2. Select OpenJDK 11 (LTS)
  3. Select HotSpot
  4. Click the Latest Release button to download.
  5. Once the file is downloaded open it and complete the installation steps.

Inside Visual Studio Code, you will need to set the salesforcedx-vscode-apex.java.home to one of the following values.

MacOS:

{
  "salesforcedx-vscode-apex.java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home"
}

Windows:

{
  "salesforcedx-vscode-apex.java.home": "C:\\Program Files\\AdoptOpenJDK\\jdk-11.0.3.7-hotspot"
}

Zulu

Zulu Java builds are TCK-tested and free to download and use without restrictions.

  1. Navigate to the Zulu download page
  2. Select version 11
  3. Select your OS
  4. Download the installer
  5. For macOS download the zip or dmg version.
  6. For Windows Download the “11”, “JDK”, “Client” version.
  7. Once the file is downloaded open it and complete the installation steps.

Inside Visual Studio Code, you will need to set the salesforcedx-vscode-apex.java.home to one of the following values.

MacOS:

{
  "salesforcedx-vscode-apex.java.home": "/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home"
}

Windows:

{
  "salesforcedx-vscode-apex.java.home": "C:\\Program Files\\Zulu\\zulu-11"
}

Oracle Java 11 (Officially Test)

  1. Navigate to the download page
  2. Click the Download button for Java SE 11.x.y (LTS)
  3. Accept the license agreement
  4. Click the download link that applies to your OS
  5. For macOS download the dmg version.
  6. For Windows Download exe version.
  7. If prompted to login, you will need to login with your Oracle account.
  8. Once the file is downloaded open it and complete the installation steps.

Inside Visual Studio Code, you will need to set the salesforcedx-vscode-apex.java.home to one of the following values.

MacOS:

{
  "salesforcedx-vscode-apex.java.home": "/Library/Java/JavaVirtualMachines/jdk-11.0.3.jdk/Contents/Home"
}

Windows:

{
  "salesforcedx-vscode-apex.java.home": "C:\\Program Files\\Java\\jdk11.0.3"
}

Oracle Java 8 (Legacy)

If you are still running Java 8 the values for salesforcedx-vscode-apex.java.home are as follows.

MacOS:

{
  "salesforcedx-vscode-apex.java.home": "/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home"
}

Windows:

{
  "salesforcedx-vscode-apex.java.home": "C:\\Program Files\\Java\\jdk1.8.0_131"
}

Feedback or Bugs | Edit this Article