Sublime Text 3 Configure Java program to run the environment __java

Source: Internet
Author: User
Tags sublime text

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.