wood burning stoves 2.0*
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "cant find file error" Watch "cant find file error" New topic

cant find file error

Adamz Preston

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

Joined: Oct 27, 2005
Posts: 19725

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.

How To Ask Questions How To Answer Questions
Tony Docherty

Joined: Aug 07, 2007
Posts: 2335
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