# Removal of unwanted imports

**URL:** <https://talk.openmrs.org/t/removal-of-unwanted-imports/32326>\
**Category:** Uncategorized\
**Created:** [February 22, 2021, 2:51pm UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326 "2021-02-22T14:51:54Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![gracebish](https://talk.openmrs.org/user_avatar/talk.openmrs.org/gracebish/32/13547_2.png) [@gracebish](https://talk.openmrs.org/u/gracebish)\
**Post date:** [February 22, 2021, 2:51pm UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/1 "2021-02-22T14:51:54Z")

</div>

Kindly advise on the best way of removing unwanted imports from code which are brought about by mvn after making a PR without closing the PR and repeating the work?

@jwnasambu @gcliff @dkayiwa

---

<div class="post-metadata">

**Author:** ![jwnasambu](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jwnasambu/32/13543_2.png) [@jwnasambu](https://talk.openmrs.org/u/jwnasambu)\
**Post date:** [February 22, 2021, 3:04pm UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/2 "2021-02-22T15:04:15Z")

</div>

Assume you are using eclipse IDE you can try any of the following methods if you haven’t tried out.

1. Go to the line of unused import, press Ctrl + 1, which is an Eclipse shortcut of a quick fix. This will show a drop-down menu to fix this error and select “remove unused imports.” It will remove that import statement from Java file the unfortunate part is it can’t remove multiple unused imports.

2. To remove multiple imports in a single click use the **"Organize Imports** which is a feature of Eclipse IDE to remove multiple or all unused imports statement. on your Menu, Select Source–\> Organize Imports. This will remove all unused imports from that Java file.

3. To remove all unused import statement from Java file is Ctrl + Shift + O, which is a **shortcut of organized import** in Eclipse, and you can say _Eclipse shortcut to remove all unused import statement_ from the Java file.

---

<div class="post-metadata">

**Author:** ![medhavi](https://talk.openmrs.org/user_avatar/talk.openmrs.org/medhavi/32/14684_2.png) [@medhavi](https://talk.openmrs.org/u/medhavi)\
**Post date:** [February 22, 2021, 3:13pm UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/3 "2021-02-22T15:13:21Z")

</div>

@jwnasambu thanks, really helpful. @gracebish if you are using Intellij then go to **Settings \> Editor \> General \>Auto Import** and check the **Optimize imports on the fly** checkbox or you can use Ctrl + Shift + O.

---

<div class="post-metadata">

**Author:** ![gracebish](https://talk.openmrs.org/user_avatar/talk.openmrs.org/gracebish/32/13547_2.png) [@gracebish](https://talk.openmrs.org/u/gracebish)\
**Post date:** [February 22, 2021, 7:50pm UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/4 "2021-02-22T19:50:17Z")

</div>

@jwnasambu @medhavi The feedback i get is

Problem while organize imports: openmrs-api/src/main/java/org/openmrs/Concept.java contains ambiguous references. User interaction required. Please advise.

---

<div class="post-metadata">

**Author:** ![medhavi](https://talk.openmrs.org/user_avatar/talk.openmrs.org/medhavi/32/14684_2.png) [@medhavi](https://talk.openmrs.org/u/medhavi)\
**Post date:** [February 23, 2021, 2:41am UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/5 "2021-02-23T02:41:26Z")

</div>

@gracebish have you tried Ctrl + Shift + O? because this shortcut also

- organize existing imports
- remove unneeded imports
- add new required imports
- add unambiguous imports on the fly

@jwnasambu what do you feel?

---

<div class="post-metadata">

**Author:** ![herbert24](https://talk.openmrs.org/user_avatar/talk.openmrs.org/herbert24/32/8178_2.png) [@herbert24](https://talk.openmrs.org/u/herbert24)\
**Post date:** [February 23, 2021, 6:25am UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/6 "2021-02-23T06:25:43Z")

</div>

> [@medhavi](#):
>
> Ctrl + Shift + O

@gracebish does this help?

---

<div class="post-metadata">

**Author:** ![gracebish](https://talk.openmrs.org/user_avatar/talk.openmrs.org/gracebish/32/13547_2.png) [@gracebish](https://talk.openmrs.org/u/gracebish)\
**Post date:** [February 23, 2021, 6:30am UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/7 "2021-02-23T06:30:18Z")

</div>

@herbert24 it has caused more robust problems than those that were existing before

---

<div class="post-metadata">

**Author:** ![medhavi](https://talk.openmrs.org/user_avatar/talk.openmrs.org/medhavi/32/14684_2.png) [@medhavi](https://talk.openmrs.org/u/medhavi)\
**Post date:** [February 23, 2021, 8:32am UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/8 "2021-02-23T08:32:12Z")

</div>

> [@gracebish](#):
>
> it has caused more robust problems than those that were existing before

Okay, @gracebish can you share what you see after entering Ctrl + Shift + O and before it?

---

<div class="post-metadata">

**Author:** ![gracebish](https://talk.openmrs.org/user_avatar/talk.openmrs.org/gracebish/32/13547_2.png) [@gracebish](https://talk.openmrs.org/u/gracebish)\
**Post date:** [February 23, 2021, 8:40am UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/9 "2021-02-23T08:40:27Z")

</div>

@medhavi could you check [TRUNK-5115-new-7:Replace use of conditional logging with slf4j parame… by gracebish · Pull Request #3645 · openmrs/openmrs-core · GitHub](https://github.com/openmrs/openmrs-core/pull/3645)?

---

<div class="post-metadata">

**Author:** ![medhavi](https://talk.openmrs.org/user_avatar/talk.openmrs.org/medhavi/32/14684_2.png) [@medhavi](https://talk.openmrs.org/u/medhavi)\
**Post date:** [February 23, 2021, 9:55am UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/10 "2021-02-23T09:55:48Z")

</div>

@gracebish I can see that you are having trouble in importing and somehow an extra line is added each time. I feel import settings are causing this problem, Can you check the setting once as explained [here](https://wiki.openmrs.org/display/docs/Install+and+Configure+Eclipse+For+OpenMRS+Development) under **Configure Java Import Order**. You can also run` mvn clean install`, as Maven plugin will re-order imports for you.

---

<div class="post-metadata">

**Author:** ![gracebish](https://talk.openmrs.org/user_avatar/talk.openmrs.org/gracebish/32/13547_2.png) [@gracebish](https://talk.openmrs.org/u/gracebish)\
**Post date:** [February 23, 2021, 12:42pm UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/11 "2021-02-23T12:42:03Z")

</div>

@medhavi my IDE is well configured

---

<div class="post-metadata">

**Author:** ![mherman22](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mherman22/32/20233_2.png) [@mherman22](https://talk.openmrs.org/u/mherman22)\
**Post date:** [February 23, 2021, 1:07pm UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/12 "2021-02-23T13:07:54Z")

</div>

How is [Unnecessary imports should be removed](https://issues.openmrs.org/plugins/servlet/mobile#issue/RA-1804)

Does it help?

---

<div class="post-metadata">

**Author:** ![medhavi](https://talk.openmrs.org/user_avatar/talk.openmrs.org/medhavi/32/14684_2.png) [@medhavi](https://talk.openmrs.org/u/medhavi)\
**Post date:** [February 23, 2021, 3:13pm UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/13 "2021-02-23T15:13:42Z")

</div>

> [@gracebish](#):
>
> @medhavi my IDE is well configured

okay, I think we are definitely missing something important .

@jwnasambu @herbert24 @dkayiwa @ibacher @sharif @gcliff can you look into it?

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [February 23, 2021, 3:34pm UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/14 "2021-02-23T15:34:06Z")

</div>

@gracebish which IDE are you using?

---

<div class="post-metadata">

**Author:** ![gracebish](https://talk.openmrs.org/user_avatar/talk.openmrs.org/gracebish/32/13547_2.png) [@gracebish](https://talk.openmrs.org/u/gracebish)\
**Post date:** [February 23, 2021, 6:02pm UTC](https://talk.openmrs.org/t/removal-of-unwanted-imports/32326/15 "2021-02-23T18:02:59Z")

</div>

@dkayiwa I am using eclipse
