Troubleshooting

Source File Must Be Named to Match a Public Class

You get a compiler error stating that a public class must be declared in a file with a certain name.

When you declare a public class, such as HelloWorld or HelloApplet in the examples found in this chapter, the name of the source file that contains the class must match the class name. For example, a public class named HelloWorld must be stored in a file named HelloWorld.java.

NoSuchMethodError: main

You get a runtime error identifying a NoSuchMethodError related to the main method.

When you execute a Java application, the interpreter attempts to call the main method on the class identified as the starting point for the program. This error indicates that either the class specified ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.