Sonarlint v3.0.0 complains about java11 missing in vsc after vsc upgrade to vsc v1.61.0

after update of vsc to v1.61.0 sonarlint stopped working, I have no java settings in settings.js userwise or in project. Worked fine before upgrade.

if I start a console it says java11, I have lots of various javas installed but only this one in path.

1 Like

Hello, thank you for your feedback!

If you don’t have anything explicitly configured, the extension will use a heuristic provided by the find-java-home NPM package to try to find the “right” one - and maybe it finds an older version, somehow.

In the event that it fails to find a suitable one, you can force it with the sonarlint.ls.javaHome property in your user settings.

Also, there might be additional details in the SonarLint Output (Ctrl+Shift+P, “SonarLint: Show SonarLint Output”).

The error links to the Java SDK, but the error message ask me to install a recent Java JRE.
After installing a recent Java JRE, it seems the Java JDK is actually required?

Edit: I installed the JDK jdk1.8.0_231, and updated the SonarLint Java Home.
It is still giving error messages. I see not solution but to disable the SonarLint plugin in VSCode

SonarLint for VSCode 3.0.0 requires a JRE 11, it won’t work with a JRE or JDK 8.

I’m getting the same error on macOS:

[Error - 10:14:26] Starting client failed
[object Object]

I tried setting the path manually:

{
  "sonarlint.ls.javaHome": "/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home"
}

The files are there:

$ /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home
$ ls
COPYRIGHT                          include
LICENSE                            javafx-src.zip
README.html                        jre
THIRDPARTYLICENSEREADME-JAVAFX.txt lib
THIRDPARTYLICENSEREADME.txt        man
bin                                release
db                                 src.zip
VScode 1.60.2
SonarLint 3.0.0

Yes, you have configured a path to a JDK 8 and SonarLint for VSCode 3.0 requires a Java 11+ runtime - see the changelog, readme and my comment above :slight_smile:

Hi Jean-Baptiste,

I was having the same problem (latest macOS) and I have OpenJDKs 8-16 installed currently.

Adding the sonarlint.ls.javaHome entry mentioned above works:

"sonarlint.ls.javaHome": "/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home",

FWIW, I use jEnv to manage Java versions. My global JDK is set to Java 8 and my project JDK is set to Java 11 (at least for the current project). I had also previously configured VSC to use JDK 11 via the java.home key in settings.json, but this was ignored.

I suspect the find-java-home NPM package was finding JDK 8. Perhaps there is a better way to find a specific/target JDK so you can specify needing JDK 11+ instead of finding an incorrect version?

Thanks!

Hello Michael, welcome to the community! And thank you for your feedback.

I agree: SonarLint could be smarter that this and try to find a Java runtime that meets its needs, instead of taking the first one it detects. I created an issue to track this.

@JBL_SonarSource

The extensions settings dialog still refers to Java 8:

  • Path to a Java Runtime Environment (8 or more recent) used to launch the SonarLint Language Server.
  • On Windows, backslashes must be escaped, e.g. C:\\Program Files\\Java\\jdk1.8.0_161
  • On macOS, this path should include the /Contents/Home directory, e.g /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home*

Good catch! I created a ticket that we’ll tackle soon. Thanks for reporting this!