I'm generating a tar file from my java program which is executed from database(Oracle 10g).I'm using the Runtime. aixCommand ="tar -cvf ccc.tat ccc.dat" String[] aixCmds = new String[]{"sh", "-c", aixCommand }; I'm getting the following Exception : java.io.IOException: can't exec:sh doesn't exist
Runtime.exec doesn't create the same kind of environemnt you have at the command line. Try something like "/usr/bin/sh" instead of "sh". It might also be better to break up the tar command into its separate pieces, so that the overall command is something like
new String[] {"sh", "-c", "tar", "-cvf", "ccc.tat", "ccc.dat" }
Here is an article that explains some of the pitfalls of using Runtime.exec.
As per your advice I used "/bin/sh"(as I located sh in /bin instead of /usr/bin) instead of "sh" and also broke the tar commang into separate pieces.I got no error but the tar file is not getting generated.But when run the same tar command on linux it's working fine.