Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Thursday, December 13, 2007

about NoSuchMethodError main in java

NoSuchMethodError main

Do you get the following error message?

Exception in thread "main" java.lang.NoSuchMethodError: main 

The following are common causes.

  1. 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.
  2. Mistyping the main header. Something is wrong with your declaration of main. It must be
        public static void main(String[] args)
    Variations in the parameter declaration are allowed, but the above is what everyone expects to see.
  3. CLASSPATH is a less likely cause. See CLASSPATH.

No comments: