1 Attachment(s)
Program that Opens/Executes a File on Windows
I made a program that could open a file on a mac and it worked fine. For some reason when I try it on Windows with this code I receive an error message.
Code :
try{
Runtime.getRuntime().exec(new String[] {"rundll32 url.dll,FileProtocolHandler",
"C:\\Documents and Settings\\Folder\\Filename"});
} catch(IOException e) {
e.printStackTrace();
}
The error message is:
java.io.IOException: Cannot run program "rundll32 url.dll,FileProtocolHandler": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java :459)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:466)
at fileFinderP.MostRecentFile.main(MostRecentFile.jav a:39)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java :452)
... 3 more
I checked and made sure the file path was right, and it was. Then I rechecked the way I specified "rundll32...." and that was correct as well. I also added with no avail the try/catch statements to see if that may help, as it was necessary for my program to work on my mac.
My entire program is attached in case that may help.
Re: Program that Opens/Executes a File on Windows
Problem solved. I just had to change my array around to:
{"rundll32", "url.dll,FileProtocolHandler", "C:\\Documents and Settings\\Folder\\Filename"}