function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Frederick H LaneFrederick H Lane 

Visual Studio Code and Java run time

As I launch V.S Code, view a new Terminal session and start working on Dev org/Scartch org and component bundles, I continually receive warnings;
"Java runtime could not be located. Install it and set its location using 'codescan.ls.javaHome' variable in VS Code settings"
I have installed both Jave 8jdk and Java 12jdk in my local PC filing system, noted the mapping e.g
c:Program File (x86)/java/bin/jdk1.8.1_221/bin

Then, within the V.S Code terminal CLI, navigated to;
File>Preferences>Settings>Salesforcedx-vscode-apex>Java: Home
and in the "Edit in Settings.json" file, I mapped the Java 8 runtime location
i.e; 
{
"javascript.updateImportsOnFileMove.enabled": "always"
}
{
"salesforcedx-vscode-apex.java.home": "/Program Files (x86)/Java/jdk1.8.0_221/bin"
}

It then runs ok, but only until I log out of the current V.S Code session, then I get a runtime error again.

What am I missing?
Alain CabonAlain Cabon

1) Try this alternative (c:\\) :  Change the salesforcedx-vscode-apex.java.home setting to the full path to your Java installation directory identified in the previous step. Note that for Visual Studio Code settings, the backslashes must be escaped (\) but forward slashes (/) don’t. 

http://​​​​​​​https://salesforce.stackexchange.com/questions/252329/vs-code-is-there-a-trail-regarding-installation-of-jre8 (http://https://salesforce.stackexchange.com/questions/252329/vs-code-is-there-a-trail-regarding-installation-of-jre8)

2) salesforcedx-vscode-apex.java.home is useless if you set at least one of the folowing environment variables (very simple).

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.homesetting.

https://salesforce.stackexchange.com/questions/212840/java-runtime-could-not-be-located-when-starting-vscode-with-the-salesforce-ext

What do you see in a DOS console for the following commands? ( cmd ) 

c:\>env|find "JAVA"

c:\>env|find "JDK"

That is another basic requirement for many softwares that use java.