I have a project for which I need to compile C programs. The project is in Java. I have to take the program into a JTextArea,(I am using Swing for GUI) , run it against a testfile and output the results into another JTextArea. But something seems to be wrong in my code.
Process p = new ProcessBuilder("c:\\MinGW\\bin\\cc.exe", "program.c").start();
program.c contains the program that user enter into TextArea, and "c:\MinGW\bin\cc.exe" is my c compiler. I checked that this is not raising any exception. It should create a file named a.exe in my current directory having program.c file, but it is not.What is the proper way to do it?
I saw two other post similar to this, but they also don't provide a simple clean solution for this. Also, I have to run the created executable file after it.
Thanks in advance.
ProcessBuilderwon't raise an exception if something goes wrong within the process (ie, the compiler fails), you should be reading the output of the process to be sure that nothing has gone wrong...execand (continue to) build theProcessusing aProcessBuilder. "I saw two other post similar to this.." Links?