HOWTO: Prevent Output Window from Closing After Running Jview.ex

Last reviewed: January 29, 1998
Article ID: Q169798
The information in this article applies to:
  • Microsoft Visual J++, versions 1.0, 1.1

SUMMARY

When you run a Java Application using Jview.exe from within the Developer Studio IDE, the MS-DOS Command Prompt Window closes immediately after the Java Application terminates. This article illustrates how to programmatically prevent the MS-DOS Window from closing immediately.

MORE INFORMATION

To prevent the MS-DOS Window from closing immediately, you can have an input statement as the last statement in your Java application. For example:

   public class Hello1
   {
      public static void main(String args[]) throws java.io.IOException
      {
         System.out.println("Hello, World!");
         System.in.read();
      }
   }

or alternatively:

   public class Hello2
   {
      public static void main(String args[])
      {
         System.out.println("Hello, World!");
         try { System.in.read(); } catch(Exception e) {};
      }
   }

This code causes the Command Prompt window to remain open until you press the enter key. This is a useful because you can see the output during the development of your Java application.

A second option is to run your Java application externally, that is outside of the Developer Studio environment. Open up a DOS command session, and navigate to your project directory. After building the project in the Developer Studio, switch to the DOS window and run Jview.exe with class file containing main as the argument to JView:

   JView myClass

REFERENCES

For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, see the following page on the Microsoft Technical Support site:

   http://support.microsoft.com/support/visualj/
   http://support.microsoft.com/support/java/

Keywords          : kbcode CmdLnUtils VJGenIss
Technology        : kbInetDev
Version           : 1.0 1.1
Platform          : WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 29, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.