I am using windows command prompt to compile a Java code. I want to send the compiler error stacktrace to my friend. Is there a way to copy the compiler stacktrace to a file.
I tried
javac helloworld.java > file.txt
to copy to a file and javac helloworld.java | clip
to direct the output to clipboard You can redirect command output into files with >
javac helloworld.java > file.txt 2>&1
2>&1
redirects stderr
(2) to stdout
(1) and both get redirected to file.txt
.
Note that you can also use >>
instead of >
to append content if you do not want to overwrite the file for every run of the command.