Organize Imports" work in Eclipse? I am writing a Hello World SWT application in Eclipse (following the instructions given...">

Why doesn't "Source> Organize Imports" work in Eclipse?

I am writing a Hello World SWT application in Eclipse (following the instructions given by Eclipse). At some point, I need to “Right-click in the Java editor and choose Source> Organize Import.

I did this on Eclipse installed on Ubuntu. This operation generated import statements at the beginning of my code. But that was not enough for my program to work. I needed to add some import statements with my hands, after which my code worked fine.

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

Does anyone have any ideas why it is not working properly?

+3
source share
2 answers

Scenario 1: The package that Eclipse needs to identify may not be in your path to the project path.

Scenario 2: Eclipse cannot resolve your class name, because in different packages there can be two different classes with the same name. In such scenarios, a pop-up dialog box appears asking you to select the appropriate class. The old version of eclipse cannot pop up, leaving you to manually find and resolve.

+2
source

Your source must be compiled without errors before any of them are applied.

+1
source

Source: https://habr.com/ru/post/1733027/


All Articles