Getting java error on executing sonar-scanner from cli

Have updated the Java version from “java-11-openjdk-11.0.11.0.9-1.el7_9.x86_64” to “java-11-openjdk-11.0.12.0.7-0.el7_9.x86_64” and updated the cacerts java path in the “Sonar-scanner” file . Post that on executing the sonar-scanner CLI command getting Java error.

Have set the Java and sonar-scanner path correct.

Sonar-Scanner Version : sonar-scanner-4.6.1.2450

Java version Update :

New Version : java-11-openjdk-11.0.12.0.7-0.el7_9.x86_64
Old Version : java-11-openjdk-11.0.11.0.9-1.el7_9.x86_64

Sonar-Scanner file update for CACERTS :

-Djavax.net.ssl.trustStore="/usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.el7_9.x86_64/lib/security/cacerts"
-Djavax.net.ssl.keyStore="/usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.el7_9.x86_64/lib/security/cacerts" \

Sonar-Scanner CLI Command : sonar-scanner -Dsonar.projectKey=test-pipeline -Dsonar.branch.name=devops

Error Message :

Usage: java [options] [args...] (to execute a class) or java [options] -jar [args...] (to execute a jar file) or java [options] -m [/] [args...] java [options] --module [/] [args...] (to execute the main class in a module) or java [options] [args] (to execute a single source-file program)

Arguments following the main class, source file, -jar , -m or --module / are passed as the arguments to main class.

where options include:

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
--class-path <class search path of directories and zip/jar files>
              A : separated list of directories, JAR archives,
              and ZIP archives to search for class files.
-p <module path>
--module-path <module path>...
              A : separated list of directories, each directory
              is a directory of modules.
--upgrade-module-path <module path>...
              A : separated list of directories, each directory
              is a directory of modules that replace upgradeable
              modules in the runtime image
--add-modules <module name>[,<module name>...]
              root modules to resolve in addition to the initial module.
              <module name> can also be ALL-DEFAULT, ALL-SYSTEM,
              ALL-MODULE-PATH.
--list-modules
              list observable modules and exit

Hi,

Welcome to the community!

What do you get when you execute java -version from the command line?

 
Ann

Hi @ganncamp ,
Happy Morning, On typing the Java -version we get the latest java version which i have set in JAVA_HOME.

Initially we were using “java-11-openjdk-11.0.11.0.9-1.el7_9.x86_64” version and able to run the sonar-scanner command. Day before yesterday we have upgraded the java version post that we are getting the issue.

Latest Java Version : java-11-openjdk-11.0.12.0.7-0.el7_9.x86_64

Modified Place :

  1. Have set the JAVA_HOME
  2. In bin/sonar_scanner
-Djavax.net.ssl.trustStore="/usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.el7_9.x86_64/lib/security/cacerts"
-Djavax.net.ssl.keyStore="/usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.el7_9.x86_64/lib/security/cacerts" \

Post that we are started to get the java error message when we run the “sonar-scanner -Dsonar.projectKey=test-pipeline -Dsonar.branch.name=devops” command .

Kindly suggest whether the sonar-scanner version is compatible for the latest version of java.

Hi @ganncamp ,

Now i have made the set-up fresh. with the same version of Java and Sonar-Scanner. And i m getting the below error message.

Sonar-Scanner Version : sonar-scanner-4.6.1.2450
Java Version : java-11-openjdk-11.0.12.0.7-0.el7_9.x86_64

Lines added in bin/sonar-scanner :

-Djavax.net.ssl.trustStore="/usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.el7_9.x86_64/lib/security/cacerts"
-Djavax.net.ssl.keyStore="/usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.el7_9.x86_64/lib/security/cacerts" \

Error Message :
Error: Could not find or load main class
Caused by: java.lang.ClassNotFoundException:

Kindly help me in understanding the issue and rectifying it.

Hi,

Maybe start by undoing your changes in bin/sonar-scanner and see if that helps.

 
Ann