Passing a string to the Windows command line-Collection of common programming errors

As I said in my comment – ‘They are executed as separate commands, they are not related just because you executed one before the other’

From the Runtime.exec( string ) javadoc –

Executes the specified command and arguments in a separate process.

You need to chain the commands together to get cmd to process your command, I believe you need to use the \k flag to specify what commands you need executed on the command line.

Runtime rt = Runtime.getRuntime();  
String start = "cmd /k ";
String cmd = "LogParser;\n" Select top 10 * into c:\temp\test9.csv from application";
rt.exec(start + cmd);

Not tested as I don’t have windows, but it should be similar to this.