Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Basic Beginner Help

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Basic Beginner Help

    Hi,

    In Windows, in a command prompt, is there a way to capture error messages generated when running a Java class file, using the syntax >java MyDemo.class?

    I've tried piping it into a text file using >java MyDemo.class > error.txt
    but this creates an empty error.txt file.

    Essentially I want to be able to paste the error into a forum post.

    Thanks,
    Steve


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Basic Beginner Help

    The default error stream always points to be displayed out to the console. You can create a new stream to be written out to for the error stream, but you can't use the redirection method in conjunction with this method (unless they are to be redirected to the same file).

    // sets the error stream to redirect all error to a file called "errors.txt". Auto-flushing is enabled
    System.setErr(new PrintStream(new FileOutputStream("errors.txt"),true);
    System.err.println("Start of error logging in errors.txt");

Similar Threads

  1. Beginner needs help with simple java assignment.
    By joachim89 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 6th, 2010, 07:53 PM
  2. Java Beginner
    By rannoune in forum Java Theory & Questions
    Replies: 3
    Last Post: December 25th, 2009, 03:30 AM
  3. I need a help ! i am beginner
    By yinky in forum Java Theory & Questions
    Replies: 3
    Last Post: September 30th, 2009, 07:22 AM
  4. Good Beginner AWT tutorial
    By helloworld922 in forum AWT / Java Swing
    Replies: 2
    Last Post: August 4th, 2009, 10:31 AM
  5. Best beginners project in Java
    By Fendaril in forum Java Theory & Questions
    Replies: 3
    Last Post: February 10th, 2009, 08:52 AM