sublim text3 配置java编译环境
菜单栏 preferences/Browse Packages.. 打开
进去user文件夹
创建JavaC.sublime-build 文件
使用记事本打开JavaC.sublime-build文件 复制粘贴这段代码:
{
"cmd": ["javac","-encoding","UTF-8","-d",".","$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java",
"encoding":"GBK",
"variants":
[
{
"name": "Run",
"shell": true,
"cmd" : ["start","cmd","/c", "java ${file_base_name} &echo. & pause"],
"working_dir": "${file_path}",
"encoding":"GBK"
}
]
}
// /c是执行完命令后关闭cmd窗口,
// /k是执行完命令后不关闭cmd窗口。
// echo. 相当于输入一个回车
// pause命令使cmd窗口按任意键后才关闭
保存后就完成了
测试代码:
import java.util.Scanner;
public class Hello {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
System.out.println("输入字符串,exit终止====>");
while (s.hasNextLine()) {
String line = s.nextLine();
if (line.equals("exit"))
break;
System.out.println("out==>"+line);
}
}
}