在iterm中运行javac,出现一大堆乱码。
> echo $LANG 显示:zh_CH.UTF-8
查看iterm中的编码,是UTF-8
解决方案A:编辑~/.bash_profile
alias javac='javac -J-Dfile.encoding=UTF-8 -encoding UTF-8 '
alias java='java -Dfile.encoding=UTF-8 '
> source ~/.bash_profile
解决方案B:
export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
乱码的问题还会重复出现在今后的学习中,有待挖掘乱码的本质成因。
以下链接以备后续学习:
1. java中可以出现的中文乱码的集中解决:http://www.2cto.com/kf/201312/265253.html
2.java开发运行出现的乱码问题 http://www.360doc.com/content/13/1205/20/14933689_334780667.shtml