getRuntime().exec() and spaces in Windows

If you are attempting to run a process from Java in Windows, and would like to use a path with spaces, let me save you some time and Googling:

String[] cmd = { “c:\Program Files\mycommand.exe” };
Process p = Runtime.getRuntime().exec(cmd);

IMPORTANT the c in c: is lowercase. This will absolutely *not* work if it is upper case.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.