How I can reutrn back to the main Java program after executing a batch file?

I have the below code which execute a batch file from a Java program. The problem is that after executing the batch file I can not return back to the main Java progarm. It ends it is execution. How I can reutrn back to the Java main program (how to make the main program to be still active after executing the batch file).

try {

Runtime rt = Runtime.getRuntime();

Process proc = rt.exec("test.bat");

} catch (Throwable t)

{

t.printStackTrace();

}

Thanks in advance

Mohamed A H

2 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    Ummm... I don't think that you'll be able to in Java. Java's memory management features may be precluding that. The garbage collector probably will decide that the Java portion is garbage when the execution is turned over to the batch file. It this point, it "collects" the memory that the Java application is loaded into. There may be some technique that I'm unaware of that allows you to stop that and resume execution. Try looking at the best reference you've got, the URL below. Otherwise, I'm guessing that this is forbidden in Java due to security. Good luck.

    Source(s): http://java.sun.com/docs/books/tutorial/ The twisted mind of me.
  • 4 years ago

    If Java is put in on your computing gadget, your computing gadget does not understand the position that is positioned. both that, or your might want to set up it. If that's already put in, you do not have the ecosystem set acceptable to point to it. i recommend re-installation it.

Still have questions? Get your answers by asking now.