/*****************************************************************************
*
* Authored by Nicolas Novello in Fall 2010
* File JSwift.java is an ultralight code editor-not quite IDE.
* Yes I reinvented the wheel... and I hope you like it. Watch out EMACS...lol
*
*
* Notes:
* Problem now is I realized that I need to be able to control the programs that iv'e compiled and ran.
* I have to have a way to kill zombie processes w/o having to pull it up in a terminal window or task * manager. Also, stdOutput is not printed until the running process is dead. In fact, a the JSwift
* window locks out completely. Iv'e dealt with server-client relationships before and they suck.
* Is there any other way to start in a new process while keeping old one awake?
******************************************************************************/
public void runApp (){
try {
int fileParentPathLength = Global.file.getParentFile().getPath().length(); //used to find program name w/o full path
systemCommand = ("java " + Global.file.getPath().substring(fileParentPathLength+1,Global.file.getPath().length()-5)); //will not work for .jar!! must change classpath somehow too!
Global.infoBox.append(systemCommand + "\n");
//I need to create separate threads from current by calling these commands:
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(systemCommand);
//gives this command to the os to let it take care of business
//then I need to somehow look for any runtime errors, exceptions...
Scanner errorScanner = new Scanner(pr.getErrorStream());
while (errorScanner.hasNext()) Global.infoBox.append((errorScanner.nextLine()) + "\n");
//and also test for what the command is reading back from the stdoutput.
//I guess Id have to put them both in a loop waiting for the process to be killed. terrible.
Scanner inputScanner = new Scanner(pr.getInputStream());
while (inputScanner.hasNext())Global.infoBox.append((inputScanner.nextLine())+"\n");