The God editor Sublime text runs Java, JavaScript, Python__python

Source: Internet
Author: User
Tags sublime text


Operating system: Windows Environment



A previous article describes the powerful God editor Sublime Text, as well as the commonly used shortcut keys.



This article mainly describes how to edit Java, JavaScript, and Python code with sublime Text.






1, Sublime Text is configured by default which languages run scripts




As you can see, the default includes C + + .... Python,ruby, etc.;



If Automatic:sublime Text is selected, the corresponding language compiler or interpreter will run the code automatically, depending on the file suffix name.



For example, run a section of JavaScript code:






Ctrl + B, you can run the code in Hello_js.js;



No browser to run the JS code, is not very good.



How did this happen?









2, the necessary environment



Running the code in Sublime text is equivalent to running the file in Windows Console (CMD);



Therefore, the environment on which language is compiled, or interpreted, must be installed and configured.









3, JavaScript environment configuration



JavaScript-dependent environments are nodejs;



3.1, install Nodejs



Download
Link: http://pan.baidu.com/s/1i5rvoUh



Password: oj6d



Remember your installation path for example: C:/Program Files (x86)/nodejs/






3.2, configure sublime text






At this point, open a file and copy the contents below.



Note the CMD path, and the encoding format.


[HTML]  View plain  copy {        "cmd":  ["c:/program files  (x86)/ Nodejs/node ", " $file "],       " File_regex ": " ^[ ]*file \ "(... *?) \ ", line  ([0-9]*)",        "Working_dir":  "${project_path:${folder} } ",       " selector ": " source.js ",       " shell ": true,       " encoding ": " Utf-8 ",        "Windows": {            "cmd":  ["c:/program  files  (x86)/nodejs/node ", " $file "]       },         "Linux": {            "cmd":  ["Killall  node; node ", " $file "]       }  }   Save with file name JaVascript.sublime-build, position by default.








3.3, a new JS file, such as Hello_js.js



Console.log (' Hello World ');



Ctrl + B, run;



Note: Build System will choose Automatic or JavaScript









4. Configuring the Java Environment



First, you need to install the JDK and configure java_home and path in the environment variables;



JDK 7 Download Link: Http://pan.baidu.com/s/1jHUsClS



Password: A5VM



Specific configuration, Java development in detail, the local environment is OK.






4.1, new file Runjava.bat, and paste into the following content



[HTML] view plain copy @ECHO off CD%~dp1 ECHO compiling%~nx1 .... IF EXIST%~n1.class (DEL%~n1.class) javac-encoding UTF-8%~nx1 IF EXIST%~n1.class (ECHO-----------OUTPUT -----------Java%~n1) Note encoding. Save and place the Runjava.bat in the Jdk/bin directory;






4.2, modify Javac.sublime-build



Follow these steps to modify the sublime Text 2 compilation system script.



1 Preferences > Browse Packages in tab. Open the Sublime package directory
2) Find Java Folder
3) Open Javac.sublime-build Replace the following



[HTML] view plain copy {"cmd": ["Runjava.bat", "$file"], "File_regex": "^ (... *?):( [0-9]*]:? ([0-9]*) "," selector ":" Source.java "," Encoding ":" cp936 "}






4.3, create a new Java file, such as Test.java





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.