The following code segment fails in windows, but works under unix:
(note: command = "ls" under unix)
The stack trace is : C:\CVS_ROOT>java -classpath Carpenter.jar carpenter.Carpenter java.io.IOException: CreateProcess: dir error=2 at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.<init>(Unknown Source) at java.lang.ProcessImpl.start(Unknown Source) at java.lang.ProcessBuilder.start(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at carpenter.Carpenter.main(Carpenter.java:17)
I'm developing under Windows.. Can anyone enlighten me as to how I can use this code in a Windows env?
Presumably, "dir" and "ls" were just example commands picked for prototyping purposes, yes? There's little/no reason to invoke them from Java for any real application, is there?
For "dir", the trick of running it via "cmd" is fine. But most things you would type into a Windows Command Prompt are separate programs and do not need a "cmd". It would be inefficient to use "cmd" for most things.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Joined: May 05, 2006
Yes.. dir and ls were simply for prototyping purposes.
I have been looking for places to help me understand the format my String cmd must be in for different operating systems. I need to be able to run (primarily) on Windows XP and on Linux. Do you guys know of any good links to help me get a handle on this?
Thanks a lot!!
-Brian J. Stinar-
Originally posted by Keith Lynn: In Windows, dir is not a standalone program. It is built into the command shell.