Hi,
My java (ver. 1.8) project builds fine (mvn clean package), but when I do SonarQube analysis (mvn sonar:sonar), I get an error:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar (default-cli) on project manipulator: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar: java.lang.UnsupportedClassVersionError: javafx/stage/Stage has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
This really has nothing to do with SonarQube. The “52.0” and “55.0” numbers refer to versions of the JDK. The former refers to Java 8, and the latter Java 11. You apparently have class files that were compiled with Java 11, but you’re attempting to run with Java 8. Java 8 cannot use class files compiled with a newer JDK. You typically control this in Maven with the “maven-compiler-plugin”, setting the “source” and “target” properties, so that all of your code is compiled with expected versions of the JDK.
The plugin javafx-maven-plugin was compiled for Java 11 so you need to run Maven with Java 11.
With Java 11, you should use <release>1.8</release> instead of <source>1.8</source><target>1.8</target> in the configuration of maven-compiler-plugin to indicate to Java compiler that source are 1.8 and that you want the generate byte code to be compatible with 1.8 (see JEP 247).
Also you probably don’t want to declare sonar-maven-plugin as a dependency as it is a Maven plugin.