HOWTO: Redirect Output from jview or wjview.

Last reviewed: January 29, 1998
Article ID: Q179021
The information in this article applies to:
  • Microsoft Visual J++, versions 1.0, 1.1
  • SDK for Java, versions 1.0, 1.5, 1.51, 2.0, 2.01

SUMMARY

This article describes two methods that can redirect output from jview or wjview.

MORE INFORMATION

Method 1

Unfortunately, there is not an option or registry setting for jview or wjview that enables Java logging. However, you can redirect the output when invoking an application like the following example:

   jview main > javalog.txt

This works for both jview and wjview.

Method 2

Or you can programmatically direct the output to a file or pipe by reassigning System.out. The following steps, which work for jview or wjview and Internet Explorer, show how this can be done:

  1. Open a new Java project and call it "test."

  2. Open a new Java source file and call it "sample."

  3. Copy and paste the following code in the file you created in step 2.

          //
          //
          // sample.java
          //
          //
          import java.io.*;
    

          public class sample {
          public static void main(String[] args) {
    
             if
          ("true".equalsIgnoreCase(System.getProperty
             ("com.ms.applet.enable.logging")
             )) {
             try
             {
               String logdir = System.getProperty("java.home");
               PrintStream ps = new PrintStream(new BufferedOutputStream
               (new FileOutputStream(new File(logdir,"javalog.txt"))), true);
          //     System.out = ps;           // comment line if using SDK 2.0
          //     System.err = ps;           // comment line if using SDK 2.0
                 System.setOut(ps);         // uncomment line if using SDK 2.0
                 System.setErr(ps);         // uncomment line if using SDK 2.0
             }
             catch (Exception e)
             {
             }
             System.out.println("SAMPLE.JAVA executed sucessfully!");
             }
             }
          }
    
    

  4. Build and execute the above project.

Javalog.txt should contain the line: "SAMPLE.JAVA executed sucessfully!".

NOTE: Javalog.txt is normally found in your Windows directory at %WINDIR%\JAVA\javalog.txt.

The ability to alter the value of System.out and other system streams may be removed or changed in the future.

REFERENCES

For additional information, please see the following articles in the Microsoft Knowledge Base:

   ARTICLE-ID: Q177177 173469
   TITLE     : HOWTO: Enabling Messages Printed Using System.out.println

   ARTICLE-ID: Q173469
   TITLE     : How to Enable the Javalog.txt File

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/

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Carl Frisk, Microsoft Corporation

Keywords          : JMisc
Technology        : kbInetDev internet
Version           : WINDOWS:1.0,1.1,1.5,1.51,2.0,2.01
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.