1. Is your file name correct?
Java requires that your file exactly match your class name.
For example, public class helloworld {.....
The file name must be helloworld. java. Check it carefully!
2. Do you have the main method in your program? Are the parameters correct?
The Declaration of the main method should be like this:
Public static void main (string [] ARGs)
In fact, if you use development tools, it will not be wrong. If you use ultraedit or another type to write a program, do not copy a word!
3,Remember, the parameters behind javac are file names, but those behind Java are class names!
This is what I made when I started learning java. Java helloworld. class, and then I will report an error. Later I realized that it should be Java helloworld.
I am making this mistake. I first read that the environment variable configuration and other settings are correct, that is, this error is reported. In the end, I found that the class name is followed by the original Java, instead of file name
4. Have you set classpath?
It is not only the content to be set during JDK installation, but also a directory to store your class files. For example, D:/class directory.
Set classpath = % classpath %; D:/class
Now, copy the helloworld. Class file to the D:/class directory, and then Java helloworld should be OK.
5. Combine points 3rd and 4th
If your class belongs to a certain package, such as Sony. test. helloworld, so according to the directory I mentioned in the 4th point, we should put helloworld. the class file is stored in the D:/class/Sony/test/directory.
During execution, you should refer to the section 3rd "execute by Class Name: Java Sony. Test. helloworld.