• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What does this error mean??

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to run the following peice of code but it is giving me the following runtime error:
java.io.IOException: CreateProcess: dir error=2
try
{
// 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 = in.read()) != -1)
{
process((char)c);
}
in.close();
}catch (IOException e)
{
}

What is the problem and how may it be fixed??
Any help greatly appreciated
Thanks,
Patrick.
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 "command.com" 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
Lewin
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For more info, see this article.
 
reply
    Bookmark Topic Watch Topic
  • New Topic