After downloading the JDK, set the environment variables first. WIN10 Setting the environment is a little different from the way it was before, write it down here.
1. In the system environment variables, divided into user variables and system variables, where the operation is in the system variable
2. Click "New", the variable is named "Java_home", the variable value is the address of the JDK, I am here for
C:\Program files\java\jdk1.8.0_121
3. Click "New" again, the variable is named "CLASSPATH", the variable value is (note semicolon)
;%java_home%\lib\dt.jar;%java_home%\lib\tools.jar;
4. Find "Path" and click "Edit" to create the following two items:
%java_home%\bin
%java_home%\jre\bin
In cmd, enter "Java" and "Javac" respectively, if the following information appears, the configuration is successful:
After configuring the environment variables, we need to configure the sublime as follows:
1. Sublime Text 3->preference->browse Packages, double-click the user folder in the open window, create a new file Java.sublime-build, open with Notepad, paste the following code and save the shutdown:
{"
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 "
}]
}
New test file, save as Hello.java:
Import Java.util.Scanner;
public class Hello {public
static void Main (String args[]) {
Scanner s = new Scanner (system.in);
System.out.println ("Input string, exit termination ====>");
while (S.hasnextline ()) {
String line = S.nextline ();
if (Line.equals ("Exit")) break
;
System.out.println ("out==>" +line);}}
3. Press Ctrl+shift+b will pop up an option, the following figure, select "Java" for compilation, and then press CTRL+SHIFT+B to select "Java Run" to run.