The declared package does not match the expected package “”

前端 未结 21 2034
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-01 09:05

I am using Eclipse and have not used Java for sometime. However, I can compile my code on the command-line just fine and generate the necessary .class files. In

21条回答
  •  情深已故
    2020-12-01 09:13

    Eclipse expects the declared package to match the directory hierarchy - so it's expecting your Java file to be in a directory called "Devices" under your source root. At the moment it looks like the file is directly in your source root. So create the appropriate directory, and move the file in there.

    Note that conventionally, packages are in lower case and include your organization name in reverse DNS order, e.g.

    com.foo.devices;
    

提交回复
热议问题