Skip to content

Instantly share code, notes, and snippets.

@karellism
Last active June 2, 2019 22:23
Show Gist options
  • Save karellism/c7250586bb34b7dba6db0ada7ea15ee2 to your computer and use it in GitHub Desktop.
Save karellism/c7250586bb34b7dba6db0ada7ea15ee2 to your computer and use it in GitHub Desktop.
How to terminate a Java app
// how to terminate a Java application
import java.io.File;
public class AppTerminate {
public static void main(String[] args) {
File file = new File("config.xml");
int errCode = 0;
if (!file.exists()) {
errCode = 1;
} else {
errCode = 0;
}
// When the error code is not zero go terminate
if (errCode > 0) {
System.exit(errCode);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment