This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes What does this error mean?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "What does this error mean??" Watch "What does this error mean??" New topic

What does this error mean??

Patrick ODonnell
Ranch Hand

Joined: Nov 28, 2001
Posts: 31
I am trying to run the following peice of code but it is giving me the following runtime error: CreateProcess: dir error=2
// Execute command
String command = "dir";
Process child = Runtime.getRuntime().exe(command);

// Get input stream to read from it
InputStream in = child.getInputStream();
int c;
while ((c = != -1)
}catch (IOException e)

What is the problem and how may it be fixed??
Any help greatly appreciated
Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214
Hi Patrick
The answer is fairly simple (or not...)
The reason why the process is failing is because of your command, it's a built in command, part of "" or "cmd.exe". If you were to choose some other way of doing a dir (e.g. by writing a simple listdir.bat and invoking that instead), then you would have no problem
best regards

I have no java certifications. This makes me a bad programmer. Ignore my post.
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
For more info, see this article.

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: What does this error mean??
jQuery in Action, 3rd edition