Exit and halt Java virtual machine
void exit(int status)
- Terminates the currently running Java virtual machine by initiating its shutdown sequence.
void halt(int status)
- Terminates the currently running Java virtual machine.
public class Main {
public static void main(String[] args) {
Runtime runtime = Runtime.getRuntime();
runtime.exit(2);
}
}