第一步,下载安装JDK并配置系统环境变量:
(1)添加JAVA_HOME,值为:C:\Program files\Java\jdk1.7.0_13 注:就是我们的安装路径
(2)编辑path,添加:%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin
(3)添加CLASSPATH,值为 .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
***注意一定要加最开始的那个点和分号,否则有可能在编译程序时报错:找不到或无法加载主类
第二步:Sublime配置
打开任意的文本编辑器,输入下面的内容,并保存为runJava.bat文件。
@ECHO OFF
cd %~dp1
ECHO Compiling %~nx1……
IF EXIST %~n1.class (
DEL %~n1.class
)
javac %~nx1
IF EXIST %~n1.class (
ECHO ———OUTPUT———
java %~n1
)
将这个文件复制到JDK的bin目录下
第三步 在Sublime中安装Package Resource Viewer,具体操作步骤如下:
(1)ctrl+shift+p打开package control;
(2)输入Install Package;
(3)搜索Package Resource Viewer并安装。
第四步 修改Javac.sublime-build
打开命令面板输入PackageResourceViewer:Open Resource 回车后输入java,回车后输入Javac.sublime-build,就能够打开我们所需要修改的文件,修改里面的内容为:
{
"shell_cmd": "runJava.bat \"$file\"",
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java",
"encoding": "GBK"
}
第五步,写一个测试程序,使用ctrl+b 运行一下,我采用的测试程序如下:
class HelloWorld {
public static void main(String[] args){
System.out.println("我是第一个程序");
}
}
我安装了这些插件:
1. "Alignment",
2. "AutoFileName",
3. "BracketHighlighter",
4. "Color Highlighter",
5. "DocBlockr",
6. "EditorConfig",
7. "Emmet",
8. "HTML-CSS-JS Prettify",
9. "JavaScript Console",
10. "jQuery",
11. "JsFormat",
12. "JSLint",
13. "LiveReload",
14. "SideBarEnhancements",
15. "SublimeLinter",
16. "Tag"
17. 然后习惯eclipse快捷键的朋友,可以使用下面这份代码,你就能像eclipse一样使用快捷键了,
进入preference --> 按键绑定--用户,粘贴下面代码,保存18. [
19. /**
20. * 常用快捷键(Sublime默认)
21. * --------------
22. *
23. * 光标一个单词一个单词的移动
24. * { "keys": ["ctrl+left"], "command": "move", "args": {"by": "words", "forward": false} },
25. * 按住shift来选文字时, 一个个单词的选而不是一个个字母
26. * { "keys": ["ctrl+shift+left"], "command": "move", "args": {"by": "words", "forward": false, "extend": true} },
27. *
28. * 类似光标一个个单词的移动
29. * { "keys": ["alt+left"], "command": "move", "args": {"by": "subwords", "forward": false} },
30. * { "keys": ["alt+shift+right"], "command": "move", "args": {"by": "subword_ends", "forward": true, "extend": true} },
31. *
32. * 缩进
33. * { "keys": ["ctrl+]"], "command": "indent" },
34. * { "keys": ["ctrl+["], "command": "unindent" },
35. *
36. * 删除整个单词
37. * { "keys": ["ctrl+backspace"], "command": "delete_word", "args": { "forward": false } },
38. * { "keys": ["ctrl+delete"], "command": "delete_word", "args": { "forward": true } },
39. *
40. * 行排序(例如选中几个JSON字段, 让这些字段名按字母顺序排序)
41. * { "keys": ["f9"], "command": "sort_lines", "args": {"case_sensitive": false} },
42. *
43. * 参考
44. * ----------------------
45. * Using Sublime Text as your IDE
46. * http://www.chromium.org/developers/sublime-text
47. *
48. * Web Development With Sublime Text 2
49. * http://www.paulund.co.uk/web-development-with-sublime-text-2
50. */
51.
52. // editor配置
53. { "keys": ["ctrl+v"], "command": "paste_and_indent" },
54. { "keys": ["ctrl+shift+v"], "command": "paste" },
55.
56. /**
57. * 适配eclipse快捷键
58. *
59. * 下面这位仁兄早就有了这个想法
60. * Eclipse shortcuts for Sublime Text 2
61. * http://icoloma.blogspot.com/2011/10/eclipse-shortcuts-for-sublime-text-2.html
62. */
63. { "keys": ["alt+/"], "command": "auto_complete" },
64. { "keys": ["ctrl+i"], "command": "reindent" },
65. // 当前行和下面一行交互位置
66. { "keys": ["alt+up"], "command": "swap_line_up" },
67. { "keys": ["alt+down"], "command": "swap_line_down" },
68. // 复制当前行到上一行
69. { "keys": ["ctrl+alt+up"], "command": "duplicate_line" },
70. // 复制当前行到下一行
71. { "keys": ["ctrl+alt+down"], "command": "duplicate_line" },
72. // 删除整行
73. { "keys": ["ctrl+d"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
74. // 光标移动到指定行
75. { "keys": ["ctrl+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
76. // 快速定位到选中的文字
77. { "keys": ["ctrl+k"], "command": "find_under_expand_skip" },
78. // { "keys": ["ctrl+shift+x"], "command": "swap_case" },
79. { "keys": ["ctrl+shift+x"], "command": "upper_case" },
80. { "keys": ["ctrl+shift+y"], "command": "lower_case" },
81. // 在当前行的下一行插入空行(这时鼠标可以在当前行的任一位置, 不一定是最后)
82. { "keys": ["shift+enter"], "command": "run_macro_file", "args": {"file": "Packages/Default/Add Line.sublime-macro"} },
83. // 定位到对于的匹配符(譬如{})(从前面定位后面时,光标要在匹配符里面,后面到前面,则反之)
84. { "keys": ["ctrl+shift+p"], "command": "move_to", "args": {"to": "brackets"} },
85. // 这个命令默认使用的是ctrl+shift+p
86. { "keys": ["ctrl+p"], "command": "show_overlay", "args": {"overlay": "command_palette"} },
87. // outline
88. { "keys": ["ctrl+o"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} },
89. // 当前文件中的关键字(方便快速查找内容)
90. { "keys": ["ctrl+alt+o"], "command": "show_overlay", "args": {"overlay": "goto", "text": "#"} },
91. // open resource
92. { "keys": ["ctrl+shift+r"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
93. // 文件内查找/替换
94. { "keys": ["ctrl+f"], "command": "show_panel", "args": {"panel": "replace"} },
95. // 全局查找/替换, 在查询结果中双击跳转到匹配位置
96. {"keys": ["ctrl+h"], "command": "show_panel", "args": {"panel": "find_in_files"} },
97.
98. // plugin配置
99. { "keys": ["alt+a"], "command": "alignment" },
100. {"keys": ["ctrl+shift+f"], "command": "js_format"}
101. ]
102.