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 JDK version 21 (Recommended), JDK version 17, or JDK version 11. 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.
Download and Install JDK
You can download the JDK from one of these locations.
Adoptium
Adoptium provides prebuilt OpenJDK binaries for free without authentication or complications.
- Navigate to the Adoptium JDK 21 download page.
- Select the installer applicable to your system.
- Download and open the downloaded file and complete the installation steps.
Zulu
Zulu Java builds are TCK-tested and free to download and use without restrictions.
- Navigate to the Zulu JDK 21 download page.
- Scroll down to Java Version Java 21 (LTS).
- Select your OS.
- Select your Architecture.
- Select your Java Package (JDK).
- Click the Download button..
- Once the file is downloaded, open it and complete the installation steps.
Oracle Java 21
- Navigate to the Oracle JDK 21 download page.
- 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.
Note: Installing from the executable correctly installs Java in the standard Java Home path (C:\Program Files) making setting the JDK path straightforward.
Update JDK Path
Update the salesforcedx-vscode-apex.java.home setting to the full pathname of the Java Runtime that is used to launch your Apex server.
- Select File > Preferences > Settings (Windows or Linux) or Code > Settings… > 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: This pathname can’t point to a location inside your project folder. Also note that backslashes must be escaped on Windows.
Some examples of folder paths to the Java 21 runtime:
MacOS:
{
"salesforcedx-vscode-apex.java.home": "/Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home"
}
Windows:
{
"salesforcedx-vscode-apex.java.home": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.3.9-hotspot"
}
Linux:
Pop! OS 20.04 (installation via aptitude):
{
"salesforcedx-vscode-apex.java.home": "/usr/lib/jvm/java-21-openjdk-amd64"
}
Arch Linux (installation via AUR using package jdk21-adoptopenjdk
):
{
"salesforcedx-vscode-apex.java.home": "/usr/lib/jvm/java-21-adoptopenjdk"
}
Troubleshooting Tips
- If you see an error message that your Java version is not supported, open the Output tab on the bottom panel of VS Code. Filter by ‘Apex’. Also review the ‘Problems’ tab to see that the Apex Language Server has been able to start.
-
For Windows, ensure you are escaping the path to your JDK location appropriately.
If your Java version is located at the following path:
`C:\Program Files\Java\jdk-21` Your Java Home path should like this: `C:\\Program Files\\Java\\jdk-21`
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
}