Runtime.getRuntime().exec("cd") returns java.io.IOException, error 2 in java
Hi,
I'm trying to execute Linux Shell command from java application and get a runtime error after executing the above line:
Exception in thread "main" java.io.IOException: Cannot run program "cd": java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:431)
at java.lang.Runtime.exec(Runtime.java:328)
at App.main(App.java:137)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 4 more
It works for other commands like "pwd", "ls -l" etc. but not "cd".
Any idea why?
thanks in advance,
tatarin
Last edited by tatarin; 04-07-2008 at 07:49 PM.
|