Comprehensive Guide: Installing and Configuring SonarQube on Windows

0xNehru
3 min readApr 3, 2024

--

In the realm of software development, ensuring code quality is paramount for delivering reliable and maintainable applications. SonarQube, an open-source platform, offers powerful code quality inspection capabilities. In this comprehensive guide, we’ll walk through the step-by-step process of installing and configuring SonarQube on a Windows system.

Step 1: Download and Install Oracle Java 17

Before installing SonarQube, ensure you have Java installed. Follow these steps:

  1. Download Oracle Java 17 from Oracle’s website.
  2. Run the downloaded installer and follow the installation wizard.
  3. Set the JAVA_HOME environment variable to C:\Program Files\Java\jdk-17\bin.

Step 2: Download and Install SonarQube

Now, let’s install SonarQube:

  1. Download the SonarQube zip file from SonarSource.
  2. Extract the contents of the zip file to C:\sonarqube-10.4.1.88267.
  3. Set the SONAR_JAVA_PATH environment variable using CMD:
set "SONAR_JAVA_PATH=C:\Program Files\Java\jdk-17\bin\java.exe"

Step 3: Start SonarQube

Start SonarQube using the following command in CMD:

Step 4: Access SonarQube Web Interface

  1. Open a web browser and navigate to http://localhost:9000.
  2. Log in with the default credentials (admin/admin).
  3. Follow the prompts to change the password.

Step 5: Install SonarScanner

SonarScanner allows you to analyze your projects for code quality. Here’s how to install it:

  1. Download SonarScanner CLI from SonarSource.
  2. Extract the contents to a directory, e.g., C:\sonar-scanner-5.0.1.3006-windows.

Step 6: Analyze Your Project

  1. Open CMD prompt.
  2. Run the SonarScanner command:
C:\sonar-scanner-5.0.1.3006-windows\bin\sonar-scanner.bat -D"sonar.projectKey=myproject" -D"sonar.sources=." -D"sonar.host.url=http://localhost:9000" -D"sonar.login=<your_token_here>"

Replace myproject with your project key and <your_token_here> with your generated token from SonarQube.

Step 7: Create and Analyze a Project in SonarQube

  1. Log in to SonarQube dashboard.
  2. Navigate to Projects tab > Create Project.

3. Set up the project using global settings.

4. Analyze your project locally using SonarScanner.

5 . Provide a token for authentication and execute the SonarScanner command.

Conclusion

Congratulations! You’ve successfully installed and configured SonarQube on your Windows system, integrated SonarScanner for code analysis, and analyzed your project for code quality. By following these steps, you’re on your way to improving the quality and maintainability of your software projects. Happy coding!

--

--