I am trying to import some existing projects into Eclipse. The structures for their packages is:
Project/
/src
/java
/a
/b
/c
Once imported in the package explorer I see:
Project
src/java
--a
--b
--c
- AClass.java
This is ok, since the classes e.g. AClass.java are defined in package: a.b.c
But in one project the structure (once imported) becomes:
Project
src
--java
--a
--b
--c
- AClass.java
And that causes the error that AClass.java is defined to be in package a.b.c
but it is actually under java.a.b.c
Why is this happening? Why in this specific project java is not ignored as part of package?
Thanks
Go to src folder of the project and copy all the code from it to some temporary location and build the project. And now copy the actual code from temporary location to project src. And run the build again. Problem will be resolved.
Go to Preferences » Java » Editor » Content Assist » Advanced. Make sure Other Java Proposals is ticked/checked. If that does not work simply close the project and reopen it.
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 one of them will be “remove unused imports.” It will remove that import statement from the Java file.
How are you creating the Eclipse projects? It sounds like you just need to put "java" as a root on on the source path here, instead of "src". You can do this by editing the build path after the import process, of course.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With