Eclipse: The declared package does not match the expected package

后端 未结 13 592
挽巷
挽巷 2020-12-25 09:03

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

13条回答
  •  死守一世寂寞
    2020-12-25 09:57

    I just ran into this problem, and since Mr. Skeet's solution did not work for me, I'll share how I solved this problem.

    It turns out that I opened the java file under the 'src' before declaring it a source directory.

    After right clicking on the 'src' directory in eclipse, selecting 'build path', and then 'Use as Source Folder'

    Close and reopen the already opened java file (F5 refreshing it did not work).

    Provided the path to the java file from "prefix1" onwards lines up with the package in the file (example from the requester's question prefix1.prefix.packagename2). This should work

    Eclipse should no longer complain about 'src.'

提交回复
热议问题