That code is valid. Have you tried to compile it by hand using scalac? Also, have you called your file "addressbook", all lowercase, like the name of the object?
Also, I found that Eclipse, for some reason, set the main class to be ".addressbook" instead of "addressbook".
I just had this problem too. The solution is to make sure eclipse created the project as Java project. Just create a new Java project and copy your class into the src folder (and import the eventual dependencies). This should fix the problem.
What you should do is, create a Java Project, but make sure you put this file in the package file of that project, otherwise you'll encounter same error.
In Eclipse, make sure you add your source folder in the project properties -> java build path -> source. Otherwise, the main() function may not be included in your project.
You need locate file .java in folder src (in Project Explorer of Eclipse) and then it run.
I have just add a file .java into project and it isn't in folder src, so I have a same error.
I put again it into src, then it was build.
In the worst case - create the project once again with all the imports from the beginning. In my case none of the other options worked. This type of error hints that there is an error in the project settings. I once managed to solve it, but once further developments were done, the error came back. Recreating everything from the beginning helped me understand and optimize some links, and now I am confident it works correctly.
File >> Import >> Existing Projects into Workspace >> Select Archive Filed >> Browse and locate file >> Finish. If its already imported some other way delete it and try it that way. I was having the same problem until i tried that.
One more thing to check: make sure that your source file contains the correct package declaration corresponding to the subdirectory it's in. The error mentioned by the OP can be seen when trying to run a "main type" declared in a file in a subdirectory but missing the package statement.
I had this problem with a Java project that I imported from the file system (under Eclipse Helios). Here's a hint: the src code didn't seem to be compiled at all, as no "bin" directory showed up.
I had to create a Java project from scratch (using the wizard), then compare the .project files of the non-working and working projects.
The project giving "Editor does not contain a main type" had this as the "buildSpec" in the .project file:
<buildSpec>
</buildSpec>
But the working project had this as the "buildSpec":
May be the file you have created is outside the src(source) folder. Trying to call the class object(from the file located in the src folder) from the .java file outside the source folder results in the same error. Copy .java file to the source folder, then build it. The error will be gone.
Make sure that your .java file is present either in the str package, or in some other package. If the java file with the main function is outside all packages, this error is thrown.
On reason for an Error of: "Editor does not contain a main type"
Error encountered in: Eclipse Neon
Operating System: Windows 10 Pro
When you copy your source folders over from a thumb-drive and leave out the Eclipse_Projects.metadata folder.
Other than a fresh install, you will have to make sure you merge the files from (Thrumb-drive)F:Eclipse_Projects.metadata.plugins .
These plug-ins are the bits and pieces of library code taken from the SDK when a class is created. I really all depends on what you-----import javax.swing.*;----- into your file. Because your transferring it over make sure to merge the ------Eclipse_Projects.metadata.plugins------ manually with a simple copy and paste, while accepting the skip feature for already present plugins in your Folder.
For windows 10: you can find your working folders following a similar pattern of file hierarchy.
C:Users>Mikes Laptop> workspace > .metadata > .plugins <---merge plugins here
Add a main method method inside the class to overcome this problem. I was facing the same issue regarding this.Now Including the main method inside my code i resolved my problem.