# Update Java version for GitHub Action

**URL:** <https://community.sonarsource.com/t/update-java-version-for-github-action/103448>\
**Category:** SonarQube Cloud\
**Tags:** scanner\
**Created:** [October 27, 2023, 10:53pm UTC](https://community.sonarsource.com/t/update-java-version-for-github-action/103448 "2023-10-27T22:53:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinns](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/vinns/32/50994_2.png) [@vinns](https://community.sonarsource.com/u/vinns)\
**Post date:** [October 27, 2023, 10:53pm UTC](https://community.sonarsource.com/t/update-java-version-for-github-action/103448/1 "2023-10-27T22:53:14Z")

</div>

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
    with:
      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:

```auto
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}
  env:
    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
    GITHUB_TOKEN: ***
    SONAR_TOKEN: ***
INFO: Scanner configuration file: /home/runner/work/spectrum/spectrum/.sonar/sonar-scanner-4.8.0.2856-linux/conf/sonar-scanner.properties
INFO: Project root configuration file: /home/runner/work/spectrum/spectrum/sonar-project.properties
INFO: SonarScanner 4.8.0.2856
INFO: Java 11.0.17 Eclipse Adoptium (64-bit)

```

---

<div class="post-metadata">

**Author:** ![felipebz](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/felipebz/32/32739_2.png) [@felipebz](https://community.sonarsource.com/u/felipebz)\
**Post date:** [October 28, 2023, 2:00am UTC](https://community.sonarsource.com/t/update-java-version-for-github-action/103448/2 "2023-10-28T02:00:20Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![vinns](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/vinns/32/50994_2.png) [@vinns](https://community.sonarsource.com/u/vinns)\
**Post date:** [October 30, 2023, 2:57am UTC](https://community.sonarsource.com/t/update-java-version-for-github-action/103448/3 "2023-10-30T02:57:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [November 6, 2023, 2:57am UTC](https://community.sonarsource.com/t/update-java-version-for-github-action/103448/4 "2023-11-06T02:57:55Z")

</div>

Closed on November 6, 2023, 2:57am UTC

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