Sublime Text 3 Configuration Java Program Runtime Environment (can introduce jar package, console input)

Source: Internet
Author: User
Tags sublime text



Spread a lot of configuration run Java articles, did not find the right, including examples, finally patchwork, for everyone to reference:



1. Sublime Text 3--->preference--->Browse Packages, double-click the user folder in the open window. To create a new file Javac.sublime-build, open it with Notepad, paste the following code and save the closing:




{
     "cmd": ["javac", "-encoding", "UTF-8", "-d", ".", "$ file"],
     "file_regex": "^ (... *?): ([0-9] *):? ([0-9] *)",
     "selector": "source.java",
     "encoding": "GBK",
     // End after executing the above command

     // The following commands need to be run by pressing Ctrl + Shift + b
     "variants": [{
         "name": "Run",
         "shell": true,
         "cmd": ["start", "cmd", "/ c", "java $ {file_base_name} & echo. & pause"],
         // / c is to close the cmd window after executing the command,
         // / k is to not close the cmd window after executing the command.
         // echo. Equivalent to entering a carriage return
         // pause command causes the cmd window to close after pressing any key
         "working_dir": "$ {file_path}",
         "encoding": "GBK"
     }]
}







2. 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("输入字符串,exit终止====>");
        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, such as, select "JavaC" to compile;


Press Ctrl+shift+b to select "JavaC Run".









Operating effect:






Sublime Text 3 Configuration Java Program Runtime Environment (can introduce jar package, console input)


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.