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
In my case I selected the error marker in the Problems tab and deleted it since the Java's file main method was being executed correctly. That is some glitch in Eclipse Neon with the multitude of plugins it has installed.
Make sure that You have created a correct package.You might get a chance to create folder instead of package
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;
Make sure you are not using default package. Create a new package with name 'devices' and copy this code inside it and use.
I resolved the problem by following these steps:
Select the project - Right click - java build path.
In source tab - you change the src
to src/main/java
.
Eclipse will reorder all the project.
I had have this sort situations when I copied classes from other packages/projects.
Menu->Project->Clean usually helps.