I want to compile a Hello World program. I use javac Hello_World.java
. However in cmd terminal window, it shows "semicolon is missing" compilation error.
How do I store this compilation error into a text file? Or even a string will do. How do I "catch" this error? I tried
javac filename.java 2 > textfile.txt
But javac still prints stderr and stdout to screen.
Get rid of the space between 2 and >
javac filename.java 2> textfile.txt
Another way is by redirecting stderr into stdout:
javac filename.java > textfile.txt 2>&1