I have three classes say alpha, beta, gamma and each of the three classes has a main
method.
Both alpha and beta classes have, inside their main
method, a try...catch...finally
block like:
public class alpha{
public static void main(String[] args){
try{
Do something;
}catch(Exception ex){
ex.printStackTrace();
}
finally{
System.exit(0);
}
}
}
public class beta{
public static void main(String[] args){
try{
Do something;
}catch(Exception ex){
ex.printStackTrace();
}
finally{
System.exit(0);
}
}
}
Now in gamma class i call main methods of alpha and beta classes to run continuously like below
public gamma{
public static void main(String[] args) {
try {
alpha.main(arg);
beta.main(arg1);
} catch (Exception e) {
e.printStackTrace();
}
}
The problem is that the code beta.main(arg1)
is never reached due to the System.exit(0)
inside the alpha class's finally
block.
Since alpha and beta are standalone applications when they executed separately they should terminate the service at the end of program.
So now this there any way to reach the beta.main(arg1)
line without much changing the actual functionality of alpha and beta classes.
Kindly let me know if you need further details. Thanks in advance...