How to Shutdown Java Virtual Machine


In this example we will show how to terminate currently running Java Virtual Machine(JVM) with halt method of Runtime class.

Source Code

package com.beginner.examples;


public class TerminateExample {

    public static void main(String[] args){
    	
    	 System.out.println("exit");		 
		 System.exit(0);
		 System.out.println("exit");
    }
    
}

Output:

exit
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments