I am building a GUI in Java (Swing) and I have to execute Java code from that. For the sake of testing simple code like printing HelloWorld in Java will be ok.
I have seen the forum questions and I just know that I have to invoke Operating System (I am using Windows7) to execute that compilation task.
Thank you.
P.S: I have tried with Runtime.getRuntime().exec() command but no success.
If you are using IDE you don’t need to call these commands.
Compile:
Run:
….
If you want to use Runtime.getRuntime().exec(). Here is an example of using Runtime.getRuntime().exec()..
“This just runs the dir command, captures its ouput and copies it to the programs stdout. Not very exciting but it shows the basic parts to use Runtime.exec(). You can also open up the process’ output and error streams. “
so you can send commands with Runtime.getRuntime().exec(), you can use javac or java commands that i have wrote above.