Let's use these two classes to demonstrate:
public static void main(String args[])
{
System.out.println("==INSIDE THE FIRST MAIN METHOD==");
String[] test = {"first", "second", "third"};
SecondMain.main(test);
}
}
public static void main(String args[])
{
System.out.println("==INSIDE THE SECOND TMAIN METHOD==");
for(String a: args)
{
System.out.println("Second Class===" + a);
}
}
}
MainIsCallingMain won't compile the way it is.Need to configure SecondMain on the classpath or compile both Class at same time.
@In eclipse please add the SecondMain in MainIsCallingMain's class path.
public class MainIsCallingMain {
public static void main(String args[])
{
System.out.println("==INSIDE THE FIRST MAIN METHOD==");
String[] test = {"first", "second", "third"};
SecondMain.main(test);
}
}
public class SecondMain {
public static void main(String args[])
{
System.out.println("==INSIDE THE SECOND TMAIN METHOD==");
for(String a: args)
{
System.out.println("Second Class===" + a);
}
}
}
MainIsCallingMain won't compile the way it is.Need to configure SecondMain on the classpath or compile both Class at same time.
@In eclipse please add the SecondMain in MainIsCallingMain's class path.
No comments:
Post a Comment