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?
Assuming you’re using bash you can run the command with
2>&1appended to the end of the command; e.gThis will redirect file descriptor #2 (stderr) into file descriptor #1 (stdout) which you’ve already directed to the named file.
You could also try:
… which should direct both stdout and stderr.