how to force program to quit in java code example Example 1: how to exit a java program System.exit(0); Example 2: java quit application System.exit(n);