Unsupported version of major.minor Sonar scanner exception

I am trying to parse my source code using SonarQube. I am trying to use sonar-scanner as a tool to run analysis from the command line. I followed the recommendations presented in this documentation: http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner

When I try to test the installation by running sonar-scanner -h , I get the following error:

 ➜ ~ sonar-scanner -h Exception in thread "main" java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/cli/Main : Unsupported major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) 

Due to an error, it looks like he did not find the right version of JAVA / JRE to run the cli tool. I understand that this tool should work with any version of Java 1.7+. I am using Oracle JDK 1.7.0_55 . I also tried using OpenJDK 1.8 , but I still get the same error. I also checked that my JAVA_HOME variable is set to the right JDK directory.

Any help in the right direction is appreciated.

+7
java sonarqube sonar-runner
source share
2 answers

After struggling with this for a while, I found the cause of the problem. The CLI examines your JAVA_HOME path variable to determine the version of Java that it should use. even hard default java and javac commands pointed to JDK 8, setting the environment variable JAVA_HOME to the root directory of JDK 8 solved the problem.

Hope this helps other people facing a similar problem.

+10
source share

this has already been said in sufficient detail here: Unsupported version of major.minor 52.0 and here: How to fix java. lang.UnsupportedClassVersionError: Unsupported version of major.minor

The rationale is that you are trying to run Sonar in Java 7 or lower when the sonar classes were compiled for java 8, thereby causing this error.

+2
source share

All Articles