简体   繁体   中英

Runtime command doesn't work anymore

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 :(

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 - ie your code is completing before the process executes.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM