Java Setup
The Apex Language Server, shipped as part of the Salesforce Apex Extension for VS Code, depends on the Java Platform, Standard Edition Development Kit (JDK). It requires an installation of either JDK version 17 (Recommended), JDK version 11, 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 can’t find your Java installation, or if you want it to use a different installation, change the salesforcedx-vscode-apex.java.home
setting.
- Select File > Preferences > Settings (Windows or Linux) or Code > Preferences > Settings (macOS).
- Search for
apex
. - 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. Note that this pathname can’t point to a location inside your project folder.
Below you’ll find instructions on how to download and configure different versions of Java.
Adoptium
Adoptium provides prebuilt OpenJDK binaries for free without authentication or complications.
- Navigate to Adoptium
- Select Temurin 17 (LTS)
- Click the Latest Release button to download.
- After the file has downloaded, open it and complete the installation steps.
Inside Visual Studio Code, set salesforcedx-vscode-apex.java.home
to one of the following values or to wherever your have installed JDK 17. For example:
MacOS:
For Mac OS X 10.5 or later, run /usr/libexec/java_home
in your Terminal to get the default JDK location. To find all installed JDKs, use /usr/libexec/java_home -V
.
{
"salesforcedx-vscode-apex.java.home": "/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home"
}
Windows:
{
"salesforcedx-vscode-apex.java.home": "C:\\Program Files\\Eclipse Adoptium\\jdk-17.0.2.8-hotspot"
}
Linux (Pop! OS 20.04, installation via aptitude):
{
"salesforcedx-vscode-apex.java.home": "/usr/lib/jvm/java-17-openjdk-amd64"
}
Zulu
Zulu Java builds are TCK-tested and free to download and use without restrictions.
- Navigate to the Zulu download page
- Click the Choose Your Download button.
- Select Java Version Java 17 (LTS).
- Select your OS.
- Select your Architecture.
- Select your Java Package (JDK).
- Download the installer.
- Once the file is downloaded open it and complete the installation steps.
Inside Visual Studio Code, set salesforcedx-vscode-apex.java.home
to one of the following values.
MacOS:
For Mac OS X 10.5 or later, run /usr/libexec/java_home
in your Terminal to get the default JDK location. To find all installed JDKs, use /usr/libexec/java_home -V
.
{
"salesforcedx-vscode-apex.java.home": "/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home"
}
Windows:
{
"salesforcedx-vscode-apex.java.home": "C:\\Program Files\\Zulu\\zulu-17"
}
Oracle Java 17 (Officially Tested)
- Navigate to the download page
- Navigate to Java SE Development Kit 17.0.2 downloads.
- Click the download link that applies to your OS
- If prompted to log in, use your Oracle account.
- Once the file is downloaded open it and complete the installation steps.
Inside Visual Studio Code, set salesforcedx-vscode-apex.java.home
to one of the following values.
MacOS:
For Mac OS X 10.5 or later, run /usr/libexec/java_home
in your Terminal to get the default JDK location. To find all installed JDKs, use /usr/libexec/java_home -V
.
{
"salesforcedx-vscode-apex.java.home": "/Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home"
}
Windows:
{
"salesforcedx-vscode-apex.java.home": "C:\\Program Files\\Java\\jdk17.0.2"
}
Oracle Java 8 (Legacy)
If you are still running Java 8 the values for salesforcedx-vscode-apex.java.home
are as follows.
MacOS:
For Mac OS X 10.5 or later, run /usr/libexec/java_home
in your Terminal to get the default JDK location. To find all installed JDKs, use /usr/libexec/java_home -V
.
{
"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"
}
Advanced Setup
By default, a JVM allocates up to one fourth of the system’s physical memory to the Apex Language Server process. If you are working on projects with more memory requirements, use the salesforcedx-vscode-apex.java.memory
setting to override the defaults. Use this setting to specify the maximum size of memory allocation in megabytes and in multiples of 1024.
{
"salesforcedx-vscode-apex.java.memory": 4096
}