Issue
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.
Solution
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.
Answered By - Cassio Seffrin
Answer Checked By - David Marino (JavaFixing Volunteer)