Wrong Major Version number when running Sonar Scanner with Java 11 - gradle

I'm currently migrating a project from java 8 to java 11, and have been using Sonar scanner, with gradle, to send the code to SonaQube. After migrating to Open JDK 11, I amd getting the following error when running the gradle sonarqube tasks:
java.lang.IllegalArgumentException: Unsupported class file major version 55
I have read online that the scanner should be run with jdk 8, even though the analysis can be run on an version of java files, but have not been able to figure this out.
Ideally, I would be able to run gradle sonarqube with the Java 11 JDK. I found another question seeming to have success with Java 11 using Maven, but their error is different, and I don't think their solution would apply to me.
Is this problem solvable, or will I need to wait for Sonar Scanner to have support for JDK 11?

If someone like me this will helpful.
Source code Java 8(55), with jenkins and sonarqube scanner.
My error was
INFO: SonarScanner 4.6.2.2472
INFO: Java 11.0.11 AdoptOpenJDK (64-bit)
.....
java.lang.IllegalArgumentException: Unsupported class file major version 55
Check this link : Why does sonar-scanner force the usage of the embedded JRE?
And Change your sonnar-scanner.bat or sonnar-scanner.sh
use_embedded_jre=false

Related

How do I get gradle 7 to work in IntelliJ IDEA?

I am having some troubles with setting up a project with gradle 7.1. I can't go below 7 because Fabric Loom 0.8+ needs gradle 7+.
The Intellij IDEA log: https://controlc.com/1c0be753
Using Gradle 7.1 and Java 16
See the related comment in IntelliJ IDEA bug tracker and this bug request on Gradle GitHub. The exception could be caused by the filesystem (FAT) and is fixed in Gradle 7.2

How to add a JRE 1.8 into Eclipse Installer JRE?

I am trying deploy my Spring Boot application to Elastic Beanstalk.
The problem that I am facing right now is, my application is developed with Tomcat 9, Java 13 and Project Facet 4.0.
So when I deployed to a AWS environment, I kept getting error. After researching, I found out AWS only support Tomcat 8, Java 8 and Project Facet 3.0.
I managed to change Project Facet 4.0 to 3.0.
But I can't add Java 8 to the project.
I downloaded the JDK 8 from Oracle, and tried open jdk-8u251-macosx-x64.dmg and run JDK 8 Update 251.pkg.
The system keeps giving me error that: "JDK 8 Update 251.pkg" can't be opened because Apple cannot check it for malicious software. This software needs to be updated.
Anyone know how to fix this problem so that I can run JRE 8 on eclipse?
Here is picture the problem that I have when I deploy the app to AWS.
An internal error occurred during: Updating AWS Elastic Beanstalk environment
Here is the thread that I tried to follow but without success:
https://github.com/aws/aws-toolkit-eclipse/issues/149.
Can you elaborate where exactly are you seeing the error? While running the JDK package or while configuration the JDK within Eclipse?
Nevertheless, I suppose your main requirement is to get your Eclipse to use Java 8.
It can be done in multiple ways.
Usually you can change Java compiler level to 1.8 from Project Settings even if you're using Java 13.
If you're using Maven, you can specify compiler source and target to Java 1.8
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Alternatively, you can download the JDK 8 zip instead of installer, unzip to any location and use that in Window > Preferences > Java > Installed JREs. Be sure to mark that one as default JRE.

Tycho build fails with with java 6

I need to compile a an eclipse RCP using maven+tycho, at the moment everything is working fine, as I configured this on my local PC.
When switching to production-building configuration, it fails, the only difference being java version used.
Works with: Java jdk1.8.0_25
Fails with: Java jdk1.6.0_45
Error message:
ATTENTION: Error injecting: org.eclipse.tycho.core.p2.P2ArtifactRepositoryLayout
java.lang.TypeNotPresentException: Type org.eclipse.tycho.core.p2.P2ArtifactRepositoryLayout not present
...
...
...
Caused by: java.lang.UnsupportedClassVersionError: org/eclipse/tycho/core/p2/P2ArtifactRepositoryLayout : Unsupported major.minor version 52.0
I can provide the full error stack if needed, but the error message seems pretty explicit already. Still, didn't find anything about it on the web, because it feels strange that this can't be done using java 1.6.
When using java jdk 8, I don't have any errors and the build is working fine till the end.
Recent versions of Tycho require Java 8 (.class file version 52.0 means Java 8). You can, however, still build against an older Java (and run tests with an older Java) using a feature called toolchains. That way, mvn runs on Java 8, while your code is compiled against Java 6.

SonarRunner Failing in Java 8

I have a java project with build system as Gradle. Recently we migrated to Java 8. After this migration sonarRunner task started failing with the following error :
05:10:51.823 INFO - Execute Findbugs 2.0.3...
05:10:56.502 INFO - Findbugs output report: /pathtoproject/build/sonar/findbugs-result.xml
The following errors occurred during analysis:
Unable to get XClass for java/util/function/BiConsumer
java.lang.ArrayIndexOutOfBoundsException: 1792
I started googling it and found out Findbugs 2.0.3 does not support I need to upgrade it and it was recommended that I should use Sonar server 5.x.x (my current sonar server is 5.4.x). I have some constraints yet I want my sonarRunner to be successful. Here are my constraints :
I can not upgrade the sonar server version (not in my hand)
Can not downgrade Java version.
I tried to search how to just upgrade the findbugs version in SonarRunner plugin that also I could not find. Please help me.

Can sonar build java 6 and java 7 projects on a single server?

We have a server that runs Sonar and previously only had Java 6 installed and everything worked fine. We now have a Java 7 project and are encountering the "Unsupported major.minor version 51.0" version when the Maven surefire plugin tries to analyze the project.
Is there a way to specify the Java version sonar should use for a specific project?
Java 7 is already installed on the server.
Thanks in advance!
Never mind found the JDK option under Advanced in the Jenkins configuration for the job.

Resources