No problem with this code.
What happens is the execution of another Java program inside.
There is a method in the Process class to get the output of the program, you need to redirect this output to your own if you want to see the result.
Here's a sample using the "modern" alternative to Runtime.exec
// Hello.java says Hello to the argument received. class Hello { public static void main ( String [] args ) { System.out.println( "Hello, "+args[ 0 ] ); } } // CallHello.java // Invokes Hello from within this java program // passing "world" as argument. import java.io.InputStream; import java.io.IOException; public class CallHello { public static void main( String [] args ) throws IOException { Process child = new ProcessBuilder("java", "Hello", "world").start(); // read byte by byte the output of that progam. InputStream in = child.getInputStream(); int c = 0; while( ( c = in.read() ) != -1 ) { // and print it System.out.print( (char)c); } } }
Output:
Hello world
source share