“Java runtime could not be located” when starting VSCode with the Salesforce Extensions

When starting VS Code (v1.21.1) with the VS Code extensions installed (v40.4) I’m getting the error message:

Java runtime could not be located. Set one using the salesforcedx-vscode-apex.java.home VS Code setting.

It seems fairly clear that I need to configure the Java runtime against the IDE. How do I go about this?

Answer

There are explicit details on the steps required for this in How do I configure the version of Java that the Apex Language Server uses?

By default, VS Code attempts to locate your local Java installation by looking for a JAVA_HOME or JDK_HOME environment variable on your computer. If VS Code cannot find your Java installation, or if you want it to use a different installation, change the salesforcedx-vscode-apex.java.home setting.

enter image description here

Note that while the message specifies the JRE the prerequisites are currently for the JDK.

{
    "salesforcedx-vscode-apex.java.home":
    "/Program Files/Java/jdk1.8.0_121"
}

Upon restarting code.exe wanted network access past the firewall.

The output window for the Apex Language Server also showed messages indicating it was running now.

enter image description here

Attribution
Source : Link , Question Author : Daniel Ballinger , Answer Author : Daniel Ballinger

Leave a Comment