How to set Java source code version

Hi
I am using SonarQube 8.2 and would like to scan Java source code (Java 1.6). But always get use “try-with-resource” that Java 1.6 does not support. How to set the correct java source code version in SonarQube. I know sonar.java.source should do it, but no idea how to set it.

Hi,

Welcome to the community!

As you have found sonar.java.source is the correct parameter to use. The docs have details on how to correctly set the value.

 
HTH!
Ann

hi

thanks for your email. I read this page also. but could not make it works. it is appreciated if you can show me the step or sample property file I should use.

從 Workspace ONE Boxer 傳送

在 2020年3月26日 20:44,G Ann Campbell via SonarSource Community sscommunity@discoursemail.com 寫下:


G
Ann Campbell

ganncamp
SonarSourcer

March 26
Hi,

Welcome to the community!

As you have found sonar.java.source is the correct parameter to use.
The docs
have details on how to correctly set the value.

HTH!
Ann

Hi,

in sonar-project.properties:

sonar.java.source=1.6

 
HTH,
Ann

still no luck. I have integrated TeamCity with SonarQube, and add “-Dsonar.java.source=1.6” in parameters. But still does not work.

Hi,

I think it’s worth a run with sonar.scanner.dumpToFile=[file name] to see what properties the scanner actually ends up with. We can go from there.

 
Ann