I have a Java program that asks the user to enter in the path to a file that needs to be executed.
the path can be something like this for example: C:/ProgramFiles/Citrix/ICA Client/pnagent.exe
I create a File
Object with this path, and check to make sure it exists, and check to make sure it's a File, and check to make sure it's executable. as far as File
is concerned, it's a completely valid Object that exists.
note: the File
object is called "script"
BUT When I run the script, I receive errors on the spaces.
Runtime rt = java.lang.Runtime.getRuntime();
Process pp = rt.exec(script.getAbsolutePath());
I am 100% the first line works correctly. The error I receive is the image below: (I have it displayed in a JOptionPane.)
What is the best way to remove my errors? Thanks in advanced!
Attempted Solution #1:
Process pp = rt.exec("\""+script.getAbsolutePath()+"\"");
When I use C:\Tools\IT Support\bookmark.htm
I get