SonarQube Installation and Code Analysis with Maven

Installation on Windows Goto:- Download Community Edition   It will download a Zip file so extract that...

Installation on Windows

  • Goto:-
  • Download Community Edition 
  • It will download a Zip file so extract that file 
  • Open Command Prompt (Run as Administrator) and change directory to bin\windows-x86-64 and run StartSonar.bat

Installation on Mac 

        brew install sonar

        brew install sonar-scanner

        sonar console

Integrate with Maven

Prerequisites :

   Java should be installed

   Some IDE (Eclipse) should be installed

   Maven should be installed

Step 1:-  Open Eclipse and provide the workspace folder (C:\Projects\Java17 in my example).

Step 2:- File-->New--->Other-->Maven Project

Step 3:- Select the option "Create a simple project( skip archetype selection).

Step 4:- Click on Next

Step 5:- Provide below details

            Group id:- com.raman

            Artifact id:- sonarproj

Step 6:- Click on the Finish button

Step 7:- Goto sonar website and create a token and keep in sone file so that if required then you can refer to this token

          SonarQube Website---> Administrator Menu ---> Security--->Users

Step 8:- Add sonar dependencies in pom.xml and also create a profile in maven for sonarqube and refer the sonar url and login (provide token which created in above step) details and save pom.xml file. Below is the sample of pom.xml file which I have configured in my project

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
<!-- -->
<!-- -->

               <sonar.login>user token value to be entered</sonar.login>

Step 9:- Write some code that you want to analyze. 

package com.raman;

import java.util.ArrayList;

public class MyClass {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
    ArrayList list1 = new ArrayList<Integer>(); 
    list1= null;
    int j = sum(1,2,3);
    int k= divide(2,0);
    public static void myfn()
        System.out.println("All Info is correct");
    //here in this function c variable is not used.
    public static int sum(int a, int b, int c) {
        return a+b;
    public static int divide(int i, int j) {
        return i/j;


Step 9:- Check that jar file is getting created in the target folder( should be created without any issue)

           cd C:\Projects\Java17\sonar

           mvn package

Step 10:-  To add this project into sonar for code analysis.

                mvn clean package sonar:sonar   

Step 11:- You should be able to see sonar project in sonar web portal.

Step 12:- Open the project in Sonar webpage and check the Overview. It may be passed in status ( if there is no major error) and Failed if the code error is not to be ignored.

Step 13:- Check the Code Smell, Then modify the application code according to the severity of the code smell issues, you can change the severity (like from Major to Info) if you think that it can be ignored or should be handled properly.



Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,git quiz,1,Git Worksheet,1,Jira,3,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SDLC Quiz,4,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
DevOpsWorld: SonarQube Installation and Code Analysis with Maven
SonarQube Installation and Code Analysis with Maven
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content