In the Terminal (Terminal. app) environment of Mac OSX in simplified Chinese, java and javac output various information such as syntax errors and array access out-of-bounds information in GBK-encoded Chinese by default.
However, the Mac terminal's default encoding is UTF-8, so javac and java will output garbled characters without configuration.
There are three solutions:
1) specify the output encoding as UTF-8
Javac J-Dfile.encoding = UTF-8
2) output in English
Export LC_ALL = en
3) iconv transcoding
Javac something | iconv-f GBK-t UTF-8
2) is the best solution for me. First, you can add this information to. profile once and for all. Second, if the output is in English, you can search for more information. After all, there are much more information in English than Chinese.
You can also see that you can set the terminal encoding to GBK. This method is not feasible for me, because most of my programs are output in UTF-8.