If you are using IDE you don't need to call these commands.
Compile:
- javac HelloWorldSwing.java
Run:
....
If you want to use Runtime.getRuntime().exec(). Here is an example of using Runtime.getRuntime().exec()..
import java.io.*;
public class TestExec {
public static void main(String[] args) {
try {
Process p = Runtime.getRuntime().exec("cmd /C dir");
BufferedReader in = new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
"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.