aspose file tools*
The moose likes I/O and Streams and the fly likes cant find file error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "cant find file error" Watch "cant find file error" New topic
Author

cant find file error

Adamz Preston
Greenhorn

Joined: Jan 19, 2013
Posts: 29
Hi, trying to run a process directly from java to see if it works... this is what comes up:

java.io.IOException: Cannot run program "C:\Documents and Settings\MOTIVE\Start Menu\Programs\Accessories\notepad.exe": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at mc.Test.main(Test.java:11)
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>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 2 more


and here is the code, please help

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

You're trying to run notepad from the Start Menu, but that contains a shortcut (.lnk file) and not an executable (.exe file). Either call the shortcut, or fix the path to call the executable correctly.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2248
    
  47
Notepad is normally on the PATH so you don't need to specify the directory. The following will work on most Win systems:

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: cant find file error