views:

54

answers:

2

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?

+2  A: 

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.

Joseph Kulandai
+1  A: 

Your source must be error free compile wise before any of these will be applied.

Thorbjørn Ravn Andersen