devxlogo

System.out Vs. System.err

System.out Vs. System.err

System.out leads the output to the standard output stream (normally mapped to the console screen). System.err leads the output to the standard error stream (and, by default to the console, as well). The idea behind having these two is that the standard output should be used for regular program output, and standard error should be used for error messages.

Both the streams can be redirected to different destinations. If it is desired to redirect the output to an output file and error messages to a different log file, than on UNIX it can be done as follows:

 java MyClass > output.log 2>error.log


This causes the regular output (using System.out) to be stored inoutput.log and error messages (using System.err) to be stored inerror.log.

If you have put error messages in your program, but you don

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist