Hi All,
If I have a main method in
Java which returns int
public static int main(
String args[])
then at the time of compiling the program we don�t get any compilation error, but at run time why a java.lang.NoSuchMethodError occurs?
My another question is also similar with the above one.
Let say I have 2 class, one is TestClass1.java and TestClass2.java
// TestClass1
class TestClass1
{
public static void main(String[] args)
{
TestClass2 testClass2 = new TestClass2();
testClass2.testMethod();
}
}
// TestClass2
class TestClass2
{
public void testMethod()
{
System.out.println("I am in testMethod of TestClass2");
//return 1;
}
}
We are calling testMethod() of TestClass2 from TestClass1. After compiling these 2 program if I execute the TestClass1 program then it runs perfectly. Now if I change the return type of testMethos() and compile only TestClass2 not the TestClass1 and run TestClass1 then an exception is thrown from main that is also java.lang.NoSuchMethodError. Is this related with the previous problem any more?
Regards,
Gourab