Solved

System.out redirect

Posted on 2002-04-05
9
899 Views
Last Modified: 2007-12-19
Anyone know of a way to redirect the output that the java engine creates to a text file? For example, if your program crashes due to a null pointer, the dos-console window prints out a list of like 15 lines or so with the error and where it occurred. Well, my console window's buffer is not always large enough for me to see what the last line of code that was executed.  Id like to somehow send this to a text file for reading.  Thanks!

0
Comment
Question by:epastoor
9 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 6921484
use System.setOut and System.setErr passing a PrintStream opened on a FileOutputStream
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6921520
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 6921717
Hai epastoor,


   It is very simple.  In order to redirect your console messages to a file,

you need to the following

for eg.,

java MyClass > console.log


after your program completion, you can open the console.log to see the outputs (System.out.println's)


All the best
Muruganantham
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 92

Expert Comment

by:objects
ID: 6921959
Depends on which OS your running, and which version of Java.
0
 
LVL 9

Expert Comment

by:yongsing
ID: 6922512
The following will redirect all exception stack trace to a file named "errors.log":

try {
  System.setErr(new PrintStream(new FileOutputStream("errors.log", true)));
} catch (FileNotFoundException fileNotFoundException) {}
0
 
LVL 3

Expert Comment

by:rjackman
ID: 6924689
u can also use the following

javac -Djavac.pipe.output=true myfile.java > errors.txt
where myfile.java is your class file for compilation

cheers
RJ
0
 
LVL 9

Expert Comment

by:Venci75
ID: 7933233
This question has been abandoned. I will make a recommendation to the moderators on its resolution in a week or two. I appreciate any comments that would help me to make a recommendation.

In the absence of responses, I may recommend
Answered by: CEHJ
Silence = you don't care

Venci75
EE Cleanup Volunteer
0
 
LVL 9

Expert Comment

by:Venci75
ID: 7973707
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: CEHJ
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8020313
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Way to decrease size of apk file 9 70
null output 3 25
maven module vs maven project 3 23
jsp login check 12 32
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question