# How to add new Java Custom rule to default Java Quality Profile?

**URL:** <https://community.sonarsource.com/t/how-to-add-new-java-custom-rule-to-default-java-quality-profile/84038>\
**Category:** SonarQube Server / Community Build\
**Tags:** sonarqube, scanner, java\
**Created:** [February 15, 2023, 7:19am UTC](https://community.sonarsource.com/t/how-to-add-new-java-custom-rule-to-default-java-quality-profile/84038 "2023-02-15T07:19:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![msulam](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/msulam/32/32190_2.png) [@msulam](https://community.sonarsource.com/u/msulam)\
**Post date:** [February 15, 2023, 7:19am UTC](https://community.sonarsource.com/t/how-to-add-new-java-custom-rule-to-default-java-quality-profile/84038/1 "2023-02-15T07:19:35Z")

</div>

Hi Team,

We are using Sonarqube \* Community Edition\* Version 9.6.1.

So we have created one custom rule for Java. Now we are just trying the newly created rule to add to the default java quality profile (sonar-way).

But we are not able to add the rule to the default java quality profile.

So is it possible to add the new rules to the default quality profiles?

Thanks,  
Murali Sulam

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [February 15, 2023, 7:37am UTC](https://community.sonarsource.com/t/how-to-add-new-java-custom-rule-to-default-java-quality-profile/84038/2 "2023-02-15T07:37:03Z")

</div>

Hi,

the builtin “Sonar way” quality profiles are read only.  
If you want to change/expand it, you need to work with a copy of “Sonar way” quality profile  
and add your custom rule there.

Gilbert

---

<div class="post-metadata">

**Author:** ![msulam](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/msulam/32/32190_2.png) [@msulam](https://community.sonarsource.com/u/msulam)\
**Post date:** [February 15, 2023, 4:46pm UTC](https://community.sonarsource.com/t/how-to-add-new-java-custom-rule-to-default-java-quality-profile/84038/3 "2023-02-15T16:46:39Z")

</div>

Hi Gilbert,

Thanks for your quick response.

But still I have some couple of follow-up questions.

1.Is there a way to attach 2 quality profiles to a project in Sonarqube.  
2.If the above scenario is not possible, is there a way to create a single quality profile consisting of two already available quality profiles.

Regards,  
Murali Sulam

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [February 16, 2023, 8:16am UTC](https://community.sonarsource.com/t/how-to-add-new-java-custom-rule-to-default-java-quality-profile/84038/4 "2023-02-16T08:16:02Z")

</div>

Hi,

1. no, a sonarqube project has one quality profile per language
2. no, but you may use this

First create a copy of the Sonar way quality profile, then expand this copy with your custom rules.  
Then if you want to add rules from another existing quality profiles use the compare feature.

i.e.  
`https://yoursonarhost/profiles/show?name=CopyOfSonarWay&language=java`  
and use compare \> select the quality profile you want rules from

![qp_compare](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/f/8/f82cc84d7cb1add9a83eab3ce6adec68eb74a1af.png)

the diff dashboard makes it easy to add rules from another quality profile

 ![compare_qp](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/e/9/e97e312b64cbc5f4820965c4ccc40be535b8b080.png)

Gilbert

---

<div class="post-metadata">

**Author:** ![msulam](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/msulam/32/32190_2.png) [@msulam](https://community.sonarsource.com/u/msulam)\
**Post date:** [February 21, 2023, 6:04am UTC](https://community.sonarsource.com/t/how-to-add-new-java-custom-rule-to-default-java-quality-profile/84038/5 "2023-02-21T06:04:12Z")

</div>

Thanks Gilbert, it really helped us…star\_struck

Regards,  
Murali Sulam
