Possible Duplicate:
Exception in thread “main” java.lang.NoSuchMethodError: main
I got the above message. The code is as follows:
class Test
{
public static void main(String ar[])
{
printf("hai");
}
}
How is this problem caused and how can I fix it?
The class which you're trying to execute doesn't have a main
method.
Since your main
method looks syntactically fine, this can have two causes:
The solution is obvious:
In addition to the problem that's causing the current exception (see BalusC's answer), the proper "Hello World" in Java is:
class Test
{
public static void main(String[] args) {
System.out.println("hai");
}
}
See: java.lang.System
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With