Chinese Character Problem With 'Javac' and 'Javap' in Mac Shell

To learn the class initialization process of java, I get this article from google. However, when I write the code to a local file and compile it with javac, I get some encoding problem with the output. The same problem happens when I run javap as well.

I can find the solution here and here. This is what I adopt:

1
2
3
4
5
6
JAVA_OPTS="${JAVA_OPTS} -Dfile.encoding=UTF-8"
# JAVA_OPTS="${JAVA_OPTS} -Dclient.encoding.override=UTF-8"
export JAVA_OPTS
JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} -Dfile.encoding=UTF-8"
export JAVA_TOOL_OPTIONS