Runtime command doesn't work anymore

412 Views Asked by At

My command is:

Runtime.getRuntime().exec("cmd /c copy /b D:\\MeAgent\\Reports\\receipt.hex lpt2:");
System.out.println("test");

In the console comes the "test", but the command is not executed and it comes no errormessage :(

1

There are 1 best solutions below

3
On

Looks like you don't escape the last backslash.

Edit - now you've fixed the obvious

When you call exec you spawn a Process. You need to wait for that process to finish.

What you've got here is a race condition - i.e. your code is completing before the process executes.

http://docs.oracle.com/javase/1.7/docs/api/java/lang/Process.html