Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why "Source > Organize Imports" does not work in Eclipse?

I am writning a Hello World SWT application in Eclipse (I follow instructions given by Eclipse). At some point I have to "Right click in the Java editor and select Source > Organize Imports".

I did it in Eclipse installed on Ubuntu. This operation has generated import statements in the beginning of my code. But it was not sufficient to make my program to work. I needed to add some import statements by hands and after that my code worked fine.

Now I am trying to do the same in Eclipse installed on Windows. In this case the situation is even worser. "Source > Organize Imports" does not change anything (it does not add any import statements to the beginning of the code).

Does anybody has any ideas why it does not work properly?


1 Answers

Scenario 1: The package that is to be identified by Eclipse may not be in your project classpath.

Scenario 2: Eclipse is not able to resolve your class name as there might be two different classes with same name in different packages. In such scenarios, it will pop-up a dialog asking you to select the appropriate class. Older version of eclipse may not pop-up leaving you to manually find and resolve.

like image 72
Joseph Avatar answered Dec 22 '25 18:12

Joseph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!