Hello.

I do not have time to view the contents. The console window closes immediately. How to leave it open?
What command java can stop the console window?

  • @ Александр1111, If ​​you are given an exhaustive answer, mark it as correct (click on the check mark next to the selected answer). - Nicolas Chabanovsky

3 answers 3

Try to run from the "command line" (Start> run> cmd.exe) ... If you are too lazy to type, write a simple bat file. In it after the lines with the launch of the compiler and the execution of the "main class" write pause.

Example bat file myrun.bat:

@echo on javac HelloWorld.java java -classpath . HelloWorld pause 

You can read about working with Java on the command line here: http://habrahabr.ru/post/125210/

    I haven't written in Java for a long time, something like

      int c = System.in.read(); 

    will wait for keyboard input.

    -

    @ Aleksandr1111 , and what kind of IDE do you study? I remember in eclipse there were no such problems.

    • In Eclipse, when debugging a program, the console window of the Eclipse program shows the contents, but when you save it to a jar file and start the program, the windows console window closes immediately. I do not have time to see the contents. - Aleksandr1111
    • It means that either my memory changes, or this moment was changed in Eclipse, or I did not understand something in the question. Then either just run from the command line, or insert a read before exiting (I understand that this is not always possible). - avp 2:49 pm

    The window closes after the application is completed. You can use System.exit () to terminate an application anywhere.

    • one
      Thank you, the only problem is in the reverse how to stop it, because I don’t have time to look through the contents - Aleksandr1111
    • one
      system ("pause"), getch () But why look at it? There is nothing good there. :-) - BuilderC
    • Thank you - Aleksandr1111
    • It is possible in more detail how to apply system("pause"), getch() , everything is underlined in red, what namespace are they from? - Aleksandr1111
    • 3
      Where does it say that it is Java? - BuilderC