SonarQube ignores JAVA_HOME

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension)
    The LTS version and normal latest version.

  • error observed (wrap logs/code around triple quote ``` for proper formatting)
    The LTS version and normal version get their java command from a line in wrapper.conf. This defaults to java. While this is fine for most people who have only one java version, it blocks people using the standard JAVA_HOME variable from getting the correct JDK with SonarQube.

  • steps to reproduce
    Install JDK 11 and 15, set the JAVA_HOME environment variable and watch SonarQube pick whatever is first in the path.

  • potential workaround
    Make the wrapper scripts check for JAVA_HOME before/after using the wrapper config.

Welcome :slight_smile:

as a develeoper running Java programs i.e. on Windows you will have
JAVA_HOME = path\to\rootfolder\of\jdk
PATH = …%JAVA_HOME%\bin…
So the default in wrapper.conf uses java, starting with the ‘standard’ Java runtime.
If you need another Java runtime, you may set it via wrapper.java.command in wrapper.conf, i.e

wrapper.java.command=C:\Program Files\Java\jdk-xx.x.x\bin\java.exe

The first entry wins, that’s expected behaviour. Some startup.bat may have
set PATH = my\important\path;%PATH% because of that.

Sorry, don’t get your point.

Maybe Sonarsource should provide Sonarqube releases with a bundled builtin Java runtime,
as others do, i.e. IntelliJ !? similar to Sonarqube scanner cli :thinking:

Gilbert