Skip to content

SonarQube setup error – java.lang.IllegalStateException: SonarQube requires Java 11+ to run – Solution – Install Java 11

This tutorial helps you install Java 11 on Linux based machines to resolve SonarQube errors.

When you are setting up the latest distribution of SonarQube on the latest Linux based systems, there are chances you would face the following exception.

WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: SonarQube requires Java 11+ to run
java.lang.IllegalStateException: SonarQube requires Java 11+ to run
        at org.sonar.application.App.checkJavaVersion(App.java:93)
        at org.sonar.application.App.start(App.java:56)
        at org.sonar.application.App.main(App.java:98)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
        at java.lang.Thread.run(Thread.java:748)

The latest version of SonarQube requires Java 11 to be setup on the system. You can just run the following set of commands to install Java 11. As simple as that.

Install OpenJDK 11.

yum -y install java-11-openjdk java-11-openjdk-devel

Create a new script setting the environment variables for Java 11.

cat > /etc/profile.d/java11.sh <<EOF 
export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac)))))
export PATH=\$PATH:\$JAVA_HOME/bin
export CLASSPATH=.:\$JAVA_HOME/jre/lib:\$JAVA_HOME/lib:\$JAVA_HOME/lib/tools.jar
EOF

Run the script file to set JAVA_HOME environment variable.

source /etc/profile.d/java11.sh

Update Java alternatives to choose the version you would like to use.

update-alternatives --config java

Check Java version to make sure the correct version of Java is set.

java -version

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.