method One:Open Sublime Text 3, click Preference, Browse Packages, double-click the user folder in the open window, create a new file Javac.sublime-build, open with Notepad, paste the following code and save close: {" CMD ": [" Javac ","-encoding "," UTF-8 ","-D ",". "," $file "]," File_regex ":" ^ (... *):( [0-9]*):? ([0-9]*) "," selector ":" Source.java "," Encoding ":" GBK ",//completion of the above command to end //The following command needs to press CTRL+SHIFT+B to run" variants ": [ { "name": "Run", & nbsp Shell: true, "cmd": ["Start", "cmd", "/C", "Java ${file_base _name} &echo. & Pause "], ///C is to close the cmd window after executing the command, /// K does not close the cmd window after executing the command. //echo. Equivalent to entering a carriage return //pause command to make the cmd window Press any key before closing "work Ing_dir ":" ${file_path} ", " encoding ":" GBK " } ]} ctrl+b compile, ctrl+shift+b run.
Method Two:1. Install the JDK and configure the environment variable 2. Create a new Runjava.bat file in the bin directory of the JDK, right-click Edit, copy and paste the following code and Save: @echo OFFCD%~dp1echo compiling%~nx1......if exist%~ N1.class (del%~n1.class) javac-encoding UTF-8%~nx1if exist%~n1.class (echo------Output------java%~N1) 3. Open Sublime Tex T 3, click Preference, Browse Packages, double-click the user folder in the open window, create a new file Javac.sublime-build, open with Notepad, paste the following code and save close: {"Shell_cmd": " Runjava.bat \ "$file \" "," File_regex ":" ^ (... *):( [0-9]*):? ([0-9]*) "," selector ":" Source.java "," Encoding ":" GBK "} can be saved in sublime Text 3 by Ctrl+b compiled Java run file, the disadvantage of this method can not be entered in the console, If the program needs to enter the content, then direct error
Sublime two methods for compiling and running Java in Text 3