Sonnarscanner run issue

I would like to integrate the Sonarscanner to the Angular project.

I am following the below link where I am trying to run the below command

sonar-scanner.bat -h - on Windows

But when I run the command its showing the below error.
JAVA_HOME not found in your environment and no executable java present in the path.

But I have installed the Java jdk 14.0.2 64 bit but still i am getting the above error.

Kindly request you to provide your inputs for the same.


Welcome to the Community, @SonarVenkat!

Make sure you have set your JAVA_HOME variable and add it to your path.

  1. Click on Windows start button
  2. Search for “advanced system settings”
  3. Click on “View advanced system settings”
  4. Click on “Advanced” tab
  5. Click on “Environment Variables…” button
  6. In the “System variables” section, add JAVA_HOME environment variable with the name as JAVA_HOME and value as the exact path to your JDK installation, e.g. C:\Program Files\Java\jdk1.8.0_60
  7. In the “System variables” section, click on PATH and click on Edit... button
  8. Append %JAVA_HOME%\bin to the end of the line. You can use a ; to separate the previous paths. If you are on Windows 10, just click on “New” button and add %JAVA_HOME%\bin and click on “OK” button.
  9. Lastly, go to command prompt and confirm:
java -version
echo %JAVA_HOME%

There are many examples of this such as shown on mkyong here.



I have already added the above steps and when i go to command product and type java -version i can see the java version number.

But as per this link - when i go to sonarscanner directory in the command prompt and execute the below command

i.e.: sonar-scanner.bat -h

Its showing an error JAVA_HOME not found in your environment and no executable java present in the path.

Please provide the entire PATH or a screenshot and let’s check it. Also, please close and reopen your shell application to restart the application, e.g. if you are using git-bash, close all git-bash windows then open a new git-bash shell window and check again.

Thanks, I have closed the command window and opened the same.

Now when i run command sonar-scanner.bat -h and sonar-scanner its giving the below output.

And I have added file in the root directory of angular project with the below code.

  1. Please let me know the sonar.projectKey is nothing but that we need to create a new project in sonarqube and generate a token and the same will be added here? and other added properties are correct?
# must be unique in a given SonarQube instance
# --- optional properties ---
# defaults to project key
sonar.projectName=Sample Anuglar Project

# defaults to 'not provided'

# Path is relative to the file. Defaults to .

# Encoding of the source code. Default is default system encoding

And below command lines are there in the file sonarscanner directory/conf/

#Configure here general information about the environment, such as SonarQube server connection details for example
#No information about specific project should appear here

#----- Default SonarQube server

#----- Default source code encoding

How the angular code will do code analysis?

Great! You have sonar-scanner running now. Please make sure to read SonarScanner usage docs first.

Now, you need to make sure to add it to your PATH environment variable so you don’t need to type the entire path to sonar-scanner, just like what you did with %JAVA_HOME%\bin earlier, just add a New entry for your path C:\User\...\sonar-scanner-\bin. After restarting command shell, you can just type sonar-scanner.bat instead of the full path to sonar-scanner.bat.

Lastly, you have the correct properties in your, but I suggest just setting the projectKey and projectName first to test things out. Run sonar-scanner.bat in your Angular code directory and check the SonarQube server at http://localhost:9000, login with the default admin user (admin) and password admin, and check your analysis there.

I have done the first part i.e. adding the new entry “C:\User…\sonar-scanner…\bin” to the Path environment variable.

When I type the sonar-scanner.bat in the angular project directory its showing the below list of lines where the project configuration file is showing as NONE and also let me know how to check the sonarqube server at http://localhost:9000?

INFO: Scanner configuration file: C:\XXXXXX\XXXXX XXXXX\Documents\XXXX\Softwares\sonar-scanner-msbuild-\sonar-scanner-\bin…\conf\
INFO: Project root configuration file: NONE
INFO: SonarScanner
INFO: Java 1.8.0_261 Oracle Corporation (32-bit)
INFO: Windows 10 10.0 x86
INFO: User cache: C:\XXXX.sonar\cache

Kindly guide me on this.

Please respond with all the commands you are typing. You are missing the file, which explains why it is missing for the “Project root configuration file” as NONE. Also, make sure you are in the angular project directory. We need all your console output in order to assist, so reply with that information and we can assist.

Also, make sure to read this page once then read it one more time: SonarScanner CLI

Here’s a youtube tutorial video that explains most of the details we have talked about and gives an example, although the SonarQube version is a little bit older, it is same concepts:

I have made one mistake so i have corrected by placing the file in the root directory of angular project and ran the code. PFB screenshot.

Then please let me know the next steps. I try to browse the URL http://localhost:9000/ in a browser its keep on loading nothing is happening. Am I doing anything wrong here?

You are not showing the entire console output log, please show the entire log.

There are 2 main steps to running an analysis with SonarQube:

  1. SonarQube as described here
  2. SonarScanner of the application

You need to make sure SonarQube is running then you can use sonar-scanner.bat on your application.

Please find the below console output log when i run the sonar-scanner.bat in the command line of angular project directory.

INFO: ------------------------------------------------------------------------
INFO: Total time: 5:02.552s
INFO: Final Memory: 4M/15M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
        at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(
        at Method)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(
        at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(
        at org.sonarsource.scanner.api.EmbeddedScanner.doStart(
        at org.sonarsource.scanner.api.EmbeddedScanner.start(
        at org.sonarsource.scanner.cli.Main.execute(
        at org.sonarsource.scanner.cli.Main.main(
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
        at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(
        at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(
        at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(
        ... 7 more
Caused by: Read timed out
        at Method)
        at org.sonarsource.scanner.api.internal.shaded.okio.Okio$
        at org.sonarsource.scanner.api.internal.shaded.okio.AsyncTimeout$
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http1.Http1ExchangeCodec$
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http1.Http1ExchangeCodec$
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.Exchange$
        at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.Util.bomAwareCharset(
        at org.sonarsource.scanner.api.internal.shaded.okhttp.ResponseBody.string(
        at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(
        at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(
        ... 10 more
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

We already have Sonarqube hosted in our company server so I can able to access and setup the project i.e. I have created a project key and token in the sonarqube server.

For, you need to set it to your company’s server, not http://localhost:9000.

For example, if your company’s sonarqube server is, then you need to set the in your file.

Thanks. Now I can able to see the analysis results in the the sonarqube server

I have three things which are pending in order to complete Sonascanner integration end to end.

  1. If you see the above attached screenshot where you can see the java version Java 1.8.0_261 (32 bit). But I have 64 bit machine where I installed the Jdk 14.0.2 64 bit and try to refer the path in the System environment variables. Then when i run the sonar scanner it’s not working because java command is not able to recognize.

  2. Can you please let me know how can we integrate the code coverage with the angular project.

  3. What would be the command to integrate the sonar scanner into Github pipeline?

Thanks for your patience.

  1. I suggest making sure you deleted the 32 bit version everywhere, double-check the PATH and environment variable JAVA_HOME, confirm in the terminal that java -version is what you expect, then replace it with 64 bit version, make updates, and check again. You might want to restart your computer since you’ve made so many changes.

  2. and 3. See my reply here on your other post: How to do Code coverage and integrated the same to the Git pipe line

I just realized that we do not support Java 14 for the SonarScanner, see Prerequisites and Overview, if you are using the SonarQube 8.5 (latest version as of today).

I am using SonarScanner msbuild 4.10.0 and Jdk 14.0.2 (64 bit) which is working fine for the dotnet web application code analysis.

Using JDK 14 may work for the SonarScanner but we can’t guarantee that it will be bug free, so you are better off using JDK 11.

Does this mean you were able to fix your Java 14 issue?

No, Sonarscanner for MSBuild used for the .NET framework where I am using below software version.
SonarScanner msbuild 4.10.0 and
Jdk 14.0.2 (64 bit)

The SonarScanner analysis part works fine for .net framework.

Now I am trying to integrate it for Angular project. I will try it now and update the same.

I have un-installed the Java 8 from my machine and now only contains Jdk 14.0.2 (64 bit) under the programs files folder where i can see the Java folder.

Then open the command prompt to check the java version. PFA what it’s showing.

Below system environment variables screenshot.

I have fixed the above issue by create new Jdk path in the system environment variable and move it to the top. PFA screenshot.