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