Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Runtime.getRuntime().exec() with spaces

807597Aug 1 2005 — edited Apr 17 2009
Hi,

I'm trying to open a file using the exec function. Everything works fine only when the path or filename contains spaces everything fails.

Runtime.getRuntime().exec("cmd.exe /C start C:\test.jpg"); --> success

Runtime.getRuntime().exec("cmd.exe /C start C:\new dir\test.jpg"); --> fails

I've tried adding quotes (\") but it's not working either... and I tried giving the filename as a envp parameter to the function exec, but this didn't do the trick neither. Any ideas? Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 15 2009
Added on Aug 1 2005
14 comments
220 views