Java Notes
NoSuchMethodError main
Do you get the following error message?
Exception in thread "main" java.lang.NoSuchMethodError: main
The following are common causes.
- File/class name mismatch. Check the file and class names -- they much match exactly, even with upper and lower case. Windows doesn't care about file names that differ only in case, but Java does. If you have trouble renaming a file to fix the case, first rename it to something different, then rename to the correct case.
- Mistyping the main header.
Something is wrong with your declaration of
main
. It must bepublic static void main(String[] args)
Variations in the parameter declaration are allowed, but the above is what everyone expects to see. - CLASSPATH is a less likely cause. See CLASSPATH.