If application throws exception, the exit code is always 0 (1 is expected).
To reproduce, compile and run this program with -XUseMserver:
$ java -XUseMServer -cp /tmp/t Main; echo $?
Exception in thread "main"
java.lang.RuntimeException: An exception
at Main.main(Main.java:3)
0
public class Main {
public static void main(String[] args) {
throw new RuntimeException("An exception");
}
}
or use non-existing class:
java -XUseMServer NonExistingClass;echo $?
Exception in thread "main"
java.lang.NoClassDefFoundError: NonExistingClass
Caused by: java.lang.ClassNotFoundException: NonExistingClass
at java.net.URLClassLoader$1.run(URLClassLoader.java:299)
at java.net.URLClassLoader$1.run(URLClassLoader.java:288)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:287)
at java.lang.ClassLoader.loadClass(ClassLoader.java:429)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:328)
at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
0
To reproduce, compile and run this program with -XUseMserver:
$ java -XUseMServer -cp /tmp/t Main; echo $?
Exception in thread "main"
java.lang.RuntimeException: An exception
at Main.main(Main.java:3)
0
public class Main {
public static void main(String[] args) {
throw new RuntimeException("An exception");
}
}
or use non-existing class:
java -XUseMServer NonExistingClass;echo $?
Exception in thread "main"
java.lang.NoClassDefFoundError: NonExistingClass
Caused by: java.lang.ClassNotFoundException: NonExistingClass
at java.net.URLClassLoader$1.run(URLClassLoader.java:299)
at java.net.URLClassLoader$1.run(URLClassLoader.java:288)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:287)
at java.lang.ClassLoader.loadClass(ClassLoader.java:429)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:328)
at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
0