Update Java version for GitHub Action

How do I properly upgrade the Java version used by sonar-scanner?

I have a open-source project in GitHub, that uses the SonarCloud GitHub Action, and I’ve tried to set up like this (inside the yaml):

  - uses: actions/setup-java@v3
      distribution: 'oracle'
      java-version: '17'

  - name: Install sonar-scanner and build-wrapper
    uses: SonarSource/sonarcloud-github-c-cpp@v1

Below is the job output from GitHub Action:

export use_embedded_jre=false # attempt to force the usage of JAVA_HOME from github workflow
sonar-scanner --define sonar.cfamily.build-wrapper-output="build_wrapper_output_directory"
  shell: /usr/bin/bash -e {0}
    BUILD_TYPE: Debug
    BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory
    JAVA_HOME: /opt/hostedtoolcache/Java_Oracle_jdk/17/x64
    JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Oracle_jdk/17/x64
    SONAR_HOST_URL: https://sonarcloud.io
    SONAR_TOKEN: ***
INFO: Scanner configuration file: /home/runner/work/spectrum/spectrum/.sonar/sonar-scanner-
INFO: Project root configuration file: /home/runner/work/spectrum/spectrum/sonar-project.properties
INFO: SonarScanner
INFO: Java 11.0.17 Eclipse Adoptium (64-bit)


You can update the action to SonarSource/sonarcloud-github-c-cpp@v2, it uses SonarScanner 5.x and JRE 17.

Hi, I looked at the GitHub repo and hadn’t noticed that there was a v2. Thanks for pointing this out!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.