954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

redirecting the output of java compilation to a text file

i tried to copy the result of the java compilation to the text file using
javac zz.java > compile.txt

It works if the program has no errors and it did not work if it have errors

polisetty
Newbie Poster
2 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

>and it did not work if it have errors.
Try to execute javac.exe as a subprocess using Runtime.exec method and get error output of subprocess using Process.getErrorStream() method.

String []cmd={"javac.exe","Sample.java"};
     Process proc=Runtime.getRuntime().exec(cmd);
     java.io.InputStream in=proc.getErrorStream();
__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

you can also try,

javac zz.java 2> compile.txt

parry_kulk
Junior Poster
Team Colleague
167 posts since Jan 2007
Reputation Points: 26
Solved Threads: 41
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You