Call the static method PressAnykey to keep to "DOS" window open.
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main{ public static void main(String[] args) { PressAnyKey(); } public static void PressAnyKey() { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Press any key..."); try { input.readLine(); } catch (Exception e) { e.printStackTrace(); } } }