Results 1 to 5 of 5
  1. #1
    hitesh_public is offline Member
    Join Date
    Aug 2010
    Rep Power

    Default how to see the previous screens of command prompt?

    Hello friends,
    While creating a program, I created a infinite loop so the program output is very long. I want to troubleshoot the program but I can't see the full output as the command prompt has reached very further. Even the scroll bar in command prompt is of no use. I am using Windows XP Professional. How can I see the full output of the program. Thanks a lot.

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Rep Power


    Right click the icon in the upper left corner of your cmd window, go to properties, go to the layout tab and increase the window buffer size. The labels might be different in your language, I'm only guessing the English names.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    Sno's Avatar
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Rep Power


    What do you mean?

    Are you trying to figure out where the infinite loop is?

    Why not post your code so we can see it and determine your infinite loop.

    or if using eclipse there is a debug mode which allows you to run your code line by line.

    And there is no relation to your OS to your program, so that comment is obsolete.
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    Another technique is to replace the System.out variable with your own PrintStream that writes to a file. Then ALL of your printed output will go into a file.
    See the setOut and setErr methods

    Here's a class I copied from some text book a long time ago
    Java Code:
    /* This program captures Standard output in a log file
    package NormsTools;
    public class SaveStdOutput extends PrintStream {
        final static boolean    debug = false;      // controls debug output
        static OutputStream logfile;
        static PrintStream oldStdout = null;
        static PrintStream oldStderr = null;
        private boolean    echoOutput = true;     //Also output to old setting
        // Constructor - we're the only one that can use it!
        private SaveStdOutput(PrintStream ps, boolean echoOutput) {
          this.echoOutput = echoOutput;   
    //       System.out.println("SaveStdOutput constructor called");
        } // end Constructor
        // Starts copying stdout and stderr to the file f.
        public static void start(String f) throws IOException {
         	  // Create/Open logfile.
        	  OutputStream os = new PrintStream(
        	               new BufferedOutputStream(
        	                   new FileOutputStream(f, true)));  // append to current
            doCommon(os, true);        
       } // end start()
        // Copy STDOUT and STDERR to an output stream
        public static void start(OutputStream os) {
            doCommon(os, true);
        } // end start()
        public static void start(OutputStream os, boolean eO) {
            doCommon(os, eO);
        } // end start()
       // Finish up
       private static void doCommon(OutputStream os, boolean echoOutput) {
            // Only allow to be called once
            if (oldStdout != null) {
                if (debug)
                    System.err.println("SaveStdOutput start() called twice");
                return;                    // Exit if already open
          logfile = os;
        	// Save old settings.
        	oldStdout = System.out;
        	oldStderr = System.err;
        	// Start redirecting the output.
        	System.setOut(new SaveStdOutput(System.out, echoOutput));
        	System.setErr(new SaveStdOutput(System.err, echoOutput));
        } // end doCommon()
        // Restores the original settings.
        public static void stop() {
            if (oldStdout == null) {
                if (debug)
                    System.err.println("SaveStdOutput stop() called before start()");
            oldStdout = null;              //Clear
            try {
            } catch (Exception ex) {
                System.err.println("SaveStdOutput stop() ex " + ex.getMessage());
        } // end stop()
        //   Override the PrintStream write methods
        public void write(int b) {
            try {
            } catch (Exception e) {
          if (echoOutput)
        } // end write()
        // PrintStream override.
        public void write(byte buf[], int off, int len) {
            try {
    	        logfile.write(buf, off, len);
            } catch (Exception e) {
          if (echoOutput)
       	   super.write(buf, off, len);  
        }  // end write()
        // Following for testing SaveStdOutput class: Comment out when done!
        public static void main(String[] args) {
            try {
                // Start capturing characters into the log file.
                // Test it.
                System.out.println("Here's is some stuff to stdout." 
                                        + new java.util.Date());
                System.err.println("Here's is some stuff to stderr.");
                System.out.println("Let's throw an exception...");
                new Exception().printStackTrace();
            } catch (Exception e) {
            } finally {
                // Stop capturing characters into the log file 
                // and restore old setup.
            System.out.println("This should be to console only!");
        } // end main() */
    }  // end class SaveStdOutput
    Last edited by Norm; 08-16-2010 at 05:04 PM.

  5. #5
    Spike_CT is offline Member
    Join Date
    Jan 2010
    Rep Power


    Or append > output.txt behind you're command

    Java Code:
    java myProgram > output.txt
    this will create a text-file named output (in you're local directory) containing the output of the program

Similar Threads

  1. CORBA command prompt
    By ntagrafix in forum Advanced Java
    Replies: 2
    Last Post: 04-06-2010, 11:35 AM
  2. Command Prompt Java
    By kelvinsmj in forum New To Java
    Replies: 8
    Last Post: 11-27-2009, 10:30 AM
  3. How to run a project with the command prompt?
    By TexanProgrammer in forum NetBeans
    Replies: 4
    Last Post: 08-05-2009, 10:19 PM
  4. how to get the values from command prompt
    By tej in forum New To Java
    Replies: 3
    Last Post: 05-02-2009, 08:32 AM
  5. help me!!!! about command prompt..
    By kureikougaiji in forum New To Java
    Replies: 2
    Last Post: 11-13-2008, 06:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts