Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error using SonarLint in Visual Studio Code (VsCode) and Java 11

I have a problem using SonarLint in visual studio code, I’ve been using very well this plugin in java 8 but arround last week, Vscode required java 11 as minimum java version and when I updated this (I keep using java 8 for my project, according to Vscode can use two versions), the plugin couldn’t start well, this is a error: [Error - 16:57:02.682] Analysis failed.

[Error - 16:57:02.683] java.lang.IllegalStateException: No files nor directories matching 'C:\Users\MyUser.m2\repository\com\sun\java\tools\11\tools-11.jar'

I know that tools.jar doesn’t exist in java 11 and I couldn’t find a jar to replace it or a way to solve this. I’m using the last version of sonarLint plugin 1.17.0

Thanks for your answers.

like image 878
chavalife17 Avatar asked Dec 23 '22 17:12

chavalife17


2 Answers

Requirements The SonarLint language server needs a Java Runtime (JRE) 8 or 11. If one is already installed on your computer, SonarLint should automatically find and use it.

If a suitable JRE cannot be found at the usual places, SonarLint will ask for your permission to download and manage its own version.

Finally, you can explicitly set the path where the JRE is installed using the sonarlint.ls.javaHome variable in VS Code settings. For instance:

{
    "sonarlint.ls.javaHome": "C:\\Program Files\\Java\\jre-11.0.11"
}

On Windows, backslashes must be escaped, e.g. C:\Program Files\Java\jdk-11.0.11 On macOS, this path should include the /Contents/Home directory, e.g /Library/Java/JavaVirtualMachines/jdk-11.0.11.jdk/Contents/Home

To analyze JavaScript and TypeScript, SonarLint will also need Node.js.

To enable the support for Java, you need the Language support for Java VSCode extension (version 0.56.0 or higher).

The support for Apex and PL/SQL is only available together with SonarQube/SonarCloud. For Apex, you'll also need the Salesforce Extension Pack VSCode extension.

like image 130
Cassio Seffrin Avatar answered Feb 08 '23 22:02

Cassio Seffrin


Go to File-> Preferences -> Settings

Then search for sonarlint to bring up its settings

Copy-paste your java directory path here. In my case, I had to escape the backslashes.

enter image description here

like image 31
Ε Г И І И О Avatar answered Feb 08 '23 23:02

Ε Г И І И О