# 5.1 Simple Analysis using SonarScanner

Below is the basic code to create the sonar-project.properties file to compile the code and analyse it.

```
#Required metadata
sonar.projectKey=org.sonarqube:<ProjectName>
sonar.projectName=Java :: Test Project:: SonarQube Scanner
sonar.projectVersion=1.0
# Comma-separated paths to directories with sources (required)
sonar.sources=src
# Language
sonar.language=java
# Encoding of the source files
sonar.sourceEncoding=UTF-8
```

## \* - REPLACE WITH APPROPRIATE CONTENTS FOR THE LINES WITH ANGULAR BRACES <>

If you want to validate the project then first you must navigate to the project folder in command prompt and hit the following command

> *sonar-scanner*

The above command requires the **sonar-project.properties** file to be available in the project location otherwise it gives error messages.After saving the above code try to run the code using the following lines

1. If you haven't set the environment variables then run using the following commands

> cd C:\\\<workspace location>\\\<ProjectName>\sonar-project.properties C:\\\<sonar-scanner-installation directory>\bin\sonar-scanner.bat

1. If you have set the environment variables set for sonar scanner then type the following command

> sonar-scanner sonar-tester.properties

![](/files/-M4S6l-JkT9ZuCudVBdQ)

After we get a success message we can view it in the dashboard of sonarQube.

![](/files/-M4S6k0DyyvrSl3U6tDh)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://n-saikiran.gitbook.io/sonarqube/how-to-use-sonarqube/51-simple-analysis-using-sonarscanner.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
