Running non-existing jar does not cause any expection/error
- by Nikolay Kuznetsov
Please, consider the following snippet which is being run from Eclipse.
Even though the external jar file does not exist no Exception is thrown and process is not null. Why is it so?
try {
Process process = Runtime.getRuntime().exec("java -jar NonExisting.jar");
if (process == null)
System.out.println("process = null");
else
System.out.println(process);
} catch (IOException e) {
System.err.println(e);
}
It prints
java.lang.ProcessImpl@1a4d139
If I run it manully from command line then there is an error:
C:\Users\workspace\Project\src>java -jar NonExisting.jar
Error: Unable to access jarfile NonExisting.jar