文章目录
问题
vscode 安装 java环境之后
public class Main{
public static void main(String[] args) {
System.out.println("哈哈");
}
}
➜ .leetcode cd "/Users/leesin/.leetcode/.vscode/" && javac -encoding utf-8 Main.java && java Main
����
要不就是
➜ .vscode javac Main.java
Main.java:3: warning: unmappable character for encoding EUC_CN
System.out.println("???");
^
Main.java:3: warning: unmappable character for encoding EUC_CN
System.out.println("???");
^
Main.java:3: warning: unmappable character for encoding EUC_CN
System.out.println("???");
^
Main.java:3: warning: unmappable character for encoding EUC_CN
System.out.println("???");
^
Main.java:3: warning: unmappable character for encoding EUC_CN
System.out.println("???");
^
Main.java:3: warning: unmappable character for encoding EUC_CN
System.out.println("???");
^
6 warnings
解决
将这句话粘贴到自己的iterm中运行发现也是不行的(自己的idea从来没有出现过问题,可能是人家优化的好吧),说明和vscode是没有关系的,是自己mac环境的问题
vi /etc/profile
加入
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
source /etc/profile
解决~
值得注意的
值得注意的是
输出这里还是乱码的暂时没有解决
我们是终端的不乱码了
完整配置
settings.json加入
//环境变量
"java.home": "/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home",
// "java.home": "/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home",
// "java.home": "/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home",
"files.exclude": {
"/.classpath": true,
" /.project": true,
"/.settings": true,
" /.factorypath": true
},
//utf8编译
"code-runner.executorMap": {
"java": "cd $dir && javac -encoding utf-8 $fileName && java $fileNameWithoutExt"
},
//自动到输出
"files.autoGuessEncoding": true,
//自动打终端
"code-runner.runInTerminal": true,
//编辑区的字体带下
"editor.fontSize": 18,
"terminal.integrated.shellArgs.windows": ["/K chcp 65001 >nul"],
//终端字体
"terminal.integrated.fontFamily": "",
//终端大小
"terminal.integrated.fontSize": 18,
/etc/profile加入
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
别忘了source