why i got this error??? Is my java installation wrong?
Exception in thread "main" java.lang.NoSuchMethodError:main
press any key to continue.............................
The JVM error shown by — Exception in thread "main" java.lang.NoSuchMethodError: main — means the launcher started but could not find a valid entry method to call. , and already pointed to the usual causes (method signature and file/class name), so below are targeted, practical checks that go beyond those basics and catch the runtime/linkage problems that often produce the same message.
Rebuild and run from a clean state:
rm -f *.class
javac MyClass.java
java -cp . MyClass Inspect the compiled class to confirm what the JVM actually sees:
javap -classpath . MyClass If running a jar, verify its contents and manifest:
jar tf myapp.jar
unzip -p myapp.jar META-INF/MANIFEST.MF Check for classpath collisions and stale artifacts: an older copy of the same class in a different directory or JAR will hide your new class. Clean all build output and remove duplicate JARs.
Verify package vs. directory layout and that the launcher uses the fully qualified class name when a package is present.
A bit of context: NoSuchMethodError is a runtime linkage issue — the JVM looked for the entry method with the modifiers and parameter type it expects, but the bytecode it loaded didn’t have a matching method. That can be caused by using an older .class, a duplicate class on the classpath, an incorrect Main-Class in a JAR manifest, or a run configuration that points at the wrong class. Cleaning the build, confirming the exact class being launched (via javap or inspecting the JAR), and ensuring the run command or IDE configuration targets the correct fully qualified class will resolve most cases.
Jump to Post— jwenting 1,905incorrect method signature for your main method usually.
incorrect method signature for your main method usually.
just check this out.
syntax for main method should be.
public static void main(String args[])
Be careful its case sensitive.
check out whether your java file name matches to that of your class name conataining main.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.