run shell script in java?

hi,
how to run shell script in java?

i have script a.sh which takes 1 argument as input and returns exit code integer.
how to handle it in java.
should i have to invoke process to execute it and then wait til it completes ?

please explain with code

thanks

haven't done this in a while, but I think it's:

try {
  java.lang.Process process = java.lang.Runtime.getRuntime().exec("command args");
  int retCode = process.exitValue();
}
catch (Exception e) {  }

If the 'exitValue()' method doesn't work, you may need to use 'getOutputStream()' to get the return value which is piped to stdout.

hth,
dv