Compiling External Programs
I'm trying to make a program that will compile another program (long story) and I keep getting caught on this one piece of code.
When I send the javac command to compile the program, the program will lockup while waiting for it to be finished. It only happens when there are multiple classes that need to be compiled with the main class.
I assume it's because javac isn't finding the other classes to compile, but I haven't had this problem before. Any suggestions?
EDIT: Ok, so I found that I can just explicitly declare each file that needs to be compiled with the Main and, while it's a pain, it's doable. Still, this has brought up another question. How can I have my program determine if the (compiled) program had error messages or not?
Thanks for the help,
~Tai
When I send the javac command to compile the program, the program will lockup while waiting for it to be finished. It only happens when there are multiple classes that need to be compiled with the main class.
I assume it's because javac isn't finding the other classes to compile, but I haven't had this problem before. Any suggestions?
try
{
MainFile = askForFile();
if(!MainFile.isFile()) throw new FileNotFoundException("Incorrect Filetype...");
this.setTitle("Please wait...");
Runtime rt = Runtime.getRuntime();
//Get the Java\Bin Path
File jPath = new File(System.getProperty("java.home"));
jPath = new File(jPath.getParent());
jPath = new File(jPath.getAbsolutePath() + File.separatorChar + "bin");
//Compile the program
Process compile = rt.exec("" + jPath.toString() + File.separatorChar + "javac " + MainFile.getName(), null, new File(MainFile.getParent()));
//Check if there were any errors...
java.io.InputStream error = compile.getErrorStream();
java.util.Scanner stream = new java.util.Scanner(error);
if(stream.hasNextLine()) throw new FileNotFoundException("Java files contained errors...");
//if(compile.exitValue() != 0) throw new FileNotFoundException("Java files contained errors...");
//Wait for compile to finish, then add info to the frame
compile.waitFor();
txtPath.setText(MainFile.getPath());
fillClasses();
}EDIT: Ok, so I found that I can just explicitly declare each file that needs to be compiled with the Main and, while it's a pain, it's doable. Still, this has brought up another question. How can I have my program determine if the (compiled) program had error messages or not?
Thanks for the help,
~Tai
