Reputation: 1421
E.g: I got a Java class with the main function implemented like this:
public class Job{
public static void main(String[] args) throws Exception{
Job jobA = new Job();
String jobName = System.getProperty("JobName");
job.DoJobA("jobName");
}
public void DoJobA(String jobName){
String configPath = System.getProperty("ConFig");
File file = new File(configPath+ "/" + jobName);
DoJobB(file);
}
}
And I another class and want to call the main function of class Job but couldn't find a way to do that! Is there any advise for me?
Upvotes: 0
Views: 384
Reputation: 15572
If you make the main method use var args then you dont need to pass in any variable
public static void main(String... args) throws Exception{
...
}
then you can just call it as
Job.main();
if you need arguments then you can pass them if.
Upvotes: 1
Reputation: 66693
You should be able to call it like you call any other static method
Job.main(yourArgs);
Upvotes: 8