I have a problem importing an external project. I go File -> Import... -> Existing Projects into Workspace, choose the folder where the project is located and everything is
The build path should contain the path 'till before' that of the package name.
For eg, if the folder structure is: src/main/java/com/example/dao
If the class containing the import statement'package com.example.dao'
complains of the incorrect package error, then, the build path should include:src/main/java
This should solve the issue.
Just go into the build path and change the source path to be src/prefix1
instead of src
.
It may be easiest to right-click on the src
directory and select "Build Path / Remove from build path", then find the src/prefix1
directory, right-click it and select "Build Path / Use as source folder".
I happened to have the same problem just now. However, the first few answers don't work for me.I propose a solution:change the .classpath file.For example,you can define the classpathentry node's path like this: path="src/prefix1/java" or path="src/prefix1/resources". Hope it can help.
Happens for me after failed builds run outside of the IDE. If cleaning your workspace doesn't work, try: 1) Delete all projects 2) Close and restart STS/eclipse, 3) Re-import the projects
src.prefix1.prefix.packagename1 src.prefix1.prefix.packagename2
Click Build path --> Remove from build path.
Now go the folder prefix1 in the folder section of your project.
Right click on it --> Build path --> Use as source folder.
Done. The package folder wont show any error now. If it still shows, just restart the project.
If you have imported an existing project, then just remove your source folders and then add them again to build path, and restart eclipse. Most of the times eclipse will keep showing the error till you restart.