Get Java 11 warning message on a dotnet build. Do I need to do anything?

  • ALM used
    GitHub
  • CI system used
    GitHub Actions
  • Scanner command used when applicable
DotnetBuild_and_Scan:
     needs: [REDACTED]
     runs-on: windows-latest
     steps:
       - uses: actions/checkout@v2
       - name: Download Front End Components
         uses: actions/download-artifact@v2.0.8
         with:
            name: dist
            path: tc-npm-assets

       - name: Get the version
         id: get_version
         run: echo "::set-output name=VERSION::$(echo 1.0.$GITHUB_RUN_NUMBER)"
         shell: bash

       - name: Install sonarscanner
         run: dotnet tool install --global dotnet-sonarscanner

       - name: Start sonarscanner
         run: dotnet sonarscanner begin /k:"[REDACTED]" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /o:"[REDACTED]" /d:sonar.exclusions="**\*.Tests\**"

       - name: Build
         run: .\Build.cmd
         env:
           VERSION: ${{ steps.get_version.outputs.VERSION }}
           NPM_TOKEN: [REDACTED]

       - name: End sonarscanner
         run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
         env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  • Languages of the repository
    .NET
    • And if you need help with pull request decoration, then the URL to the PR too
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)

This is the error message I see in the SonarCloud interface

The version of Java (1.8.0_275) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 11. Read more here

This build doesn’t contain Java. The GitHub Action runner just happens to not have Java 11.
Do I need to worry?
If so what should I do?

Hi @Vincent-FundApps

Yes, by default GitHub (And Azure) windows agent still use JDK 8.

We will stop accepting analysis on this version of Java anytime soon, so i suggest that you setup your JAVA_HOME variable to target at least JDK 11 (which is already installed on the runner image)

- script: |
    echo "##vso[task.setvariable variable=JAVA_HOME]$(JAVA_HOME_11_X64)"
    echo "##vso[task.setvariable variable=PATH]$(JAVA_HOME_11_X64)\bin;$(PATH)"
  displayName: "Set java version"

HTH,
Mickaël

1 Like

Thank you @mickaelcaro.

I believe the script you’ve provided only works for Azure DevOps.

For anyone trying to solve this easily for GitHub Actions I recommend this:

   - uses: actions/setup-java@v1
     with:
        java-version: '11.0.9'
        architecture: x64
1 Like