Balaji Krishnan wrote:I am invoking a java program from bash shell script. I want to get the return status of the java program in shell. If there is a run time exception or processing error occurs, set return code to 1 and get in the shell script. I know System.exit(1) would do that, but it also stops JVM instance(which is costly and i don't want that to happen).
Is there any other possible way to perform this?
Not that I know of, since control won't return to the shell
until the JVM exits. I suppose you could execute the program in the background and have it communicate via some sort of flag file, but that is likely to be a
lot slower than simply exiting the program.
Also: if your program throws an exception, why
wouldn't you want it to exit?
Don't start worrying about efficiency until you have a
working solution. And even then, don't start putting in
kluges until you can
prove that your solution is
too slow.
Donald Knuth wrote:Premature optimization is the root of all evil.
and premature
speculative optimization is the worst kind of all.
Winston