tzim
tzim

Reputation: 1765

Java redirect exception to file

I want to redirect FULL output of my program to a file (including Exceptions) in bash. I can't change content of class. I run it like that:

java -Djava.security.manager -Djava.security.policy=JLPPolicy -Xmx16M -Xms2M -cp /var/tomcat/bin/ Main > File

Exceptions are send to console, which is bad for me. Can I do something with it?

Upvotes: 1

Views: 2962

Answers (1)

Adamski
Adamski

Reputation: 54705

Assuming you're using bash you can run the command with 2>&1 appended to the end of the command; e.g

> File 2>&1

This will redirect file descriptor #2 (stderr) into file descriptor #1 (stdout) which you've already directed to the named file.

You could also try:

>& File

... which should direct both stdout and stderr.

Upvotes: 5

Related Questions