java!!!!please help me?

Question by hayatte: java!!!!please help me?
well i wrote this i did the compilation but it gave me this msg when running Exception in thread “main” java.lang .NoSuchMethodError:main

the thing i wrote was the following
public class MainClass

{

}

class Demo1
{
public static void main (String [] args)
{
System.out.println(“welcome to java programming”);

}
}
please could u explain it in a simple way !!!!!and why this happened
please could u explain it in a simple way !!!!!and why this happened

Best answer:

Answer by M. L.
You have two classes here. MainClass, which has nothing in it, and Demo1, which has your main(). If you ran your program pointing to MainClass, then you’ll get what you see there.

Either:
1) Move your main() method into MainClass

2) Execute your program using Demo1 as the main class.

NOTE: If these two classes are in the same file, I would HIGHLY recommend separating them out.

What do you think? Answer below!

You can leave a response, or trackback from your own site.

One Response to “java!!!!please help me?”

  1. James K says:

    Get rid of:
    public class MainClass
    {

    }

    and try it again

Leave a Reply

You must be logged in to post a comment.

Powered by Yahoo! Answers