I\'ve got a single threaded app that should set the DOS errorlevel to something non-zero if there is a problem. Is it better to throw a RuntimeException, or to use System.ex
The APP itself should use System.exit. It's its interface with the calling environment (script). Any internal component of course should use Exception. When you put it together it can be the both of'em:
Application.main(...) {
parse(args);
check(...);
try {
MyObject o = ...;
o.doMyStuff();
} catch (Exception e) {
System.err.println("Oops, something went wrong!"); // by example, or use a logging framework! // anyway in a shell app System.in/out/err IS my interface with the outworld
System.exit(ERROR_CODE);
}
System.out.println("Worked!");
}