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 Java 8 in Action this week in the Java 8 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: 19556
    
  16

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: 1950
    
  28
Notepad is normally on the PATH so you don't need to specify the directory. The following will work on most Win systems:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cant find file error
 
Similar Threads
put an applet into a web page
Problem in process
command execution error
run native move command in Java
how to synchronize the databases(different locations)