Is sonar using different version of java when doing analysis?

I have a gradle project with java version 17.This project has a code that uses URL constructor which is imported from java.net and its not deprecated in this version of java (17), but after analyzing the project with sonar. Sonar considers URL as deprecated.

Hi,

Welcome to the community!

Probably this is about the JRE auto-provisioning. The scanner is automatically providing the version of Java it wants to run with. You haven’t provided your context, but the latest SonarQube versions require J21.

That puts you in the “project-specific JDK” situation, so you’ll want to set sonar.java.jdkHome to point to your J17 install so analysis evaluates your code against the right version of Java.

 
Ann