sublime-Configuring the Java environment on the sublime Text3

Source: Internet
Author: User

First of all, the landlord is engaged in Android and Java, so has been using Android studio and Eclipse to write Java, because recently in the study of PHP, so the use of sublime Text3. And today's whim in sublime Text3 write Java, because recently landlord also do interview questions, every time to open eclipse feel very troublesome, so want to write Java on Sublime Text3.

Landlord on the Internet to find some of the configuration of the Java environment, and then use a set of suitable for their own configuration, very simple oh.

Configuration of 1.java Environment variables

The landlord's Java environment variable is different from other people on the network, this configuration method is my own groping out. Here, I'll simply show you

(1). Java_home variable

E:\Application\java\jdk\jdk

This variable landlord is defined in the user variable, perhaps other tutorial tutorials require definition in the system variables, the specific feasibility of no, you can try it yourself.

(2). Path variable

%java_home%\bin

This variable I also defined in the user variable, own new, on-line other tutorials may be directly in the system variable path behind the addition of content, whether practical, you can try.

(3). Classhome variable

%java_home%\lib

This variable i have defined in the system variable, let's take a look. This variable will add some content when you configure the Java environment for Sublime Text3 later, just to be reminded here.

With the above configuration, we have no problem with the use of Java, Javac, and java-version under the cmd command.

2. Configuring the Java environment on sublime Text3

(1). Create a new Javac.sublime-build file

First of all, I would like to state here that the other tutorials on the Web say: Locate the Packages folder in the sublime installation directory, find the Java.sublime-package file in it, open it with the decompression software, and edit the contents.

However, I do not do this here, nor edit the contents of the Java.sublime-package. My operation is: Find tools---build system->new build System in Sublime Text3, add content:

{  "shell_cmd": "Runjava.bat \" $file \ "",  "File_regex": "^ (... *):( [0-9]*):? ([0-9]*) ",  " selector ":" Source.java ",   " encoding ":" UTF-8 "}

It is then saved, and the file name is Javac.sublime-build.

At this point, we write a Java program on sublime Text3 to compile the words will appear: [Shell_cmd:runJava.bat "E:\Application\sublime\workspace\java\Demo.java"] A similar error. Next we need to do the next step.

(2). Create a new Runjava.bat file

Second, we need to create a new Runjava.bat file in the bin directory under the JDK's installation directory, as follows:

  @echo off  cd%~dp1  %~  nx1 ... if exist%~n1. class (  %~n1.  class  %~if exist%~n1.  Class------Output------%~N1)

At this point, if you compile, there is no previous problem, hint:------output------, but there is nothing under the output.

(3). Add your Java code path to the Classpath

Assuming that my JAVA classes are placed under E:\Application\sublime\workspace\java, the CLASSPATH variable at this time is%java_home%\lib; E:\Application\sublime\workspace\java, the back section is the path to the Java code we added.

After the configuration above, we found that we can compile and run the Java code properly. Note that the configuration is over, remember to restart the sublime Text3 software!

For example: write the following code on the sublime Text3:

Importjava.util.List;Importjava.util.ArrayList; Public classdemo{Privatelist<string> list =NewArraylist<>();  PublicDemo () {List.add ("11"); List.add ("22"); List.add ("33"); List.add ("44"); }     Public Static voidMain (String args[]) {Demo demo=NewDemo ();  for(inti = 0; I < demo.list.size (); i++) {System.out.println (Demo.list.get (i)); }    }}

Then run:

Compiling Demo.java ... ------Output------112233441.0s]

Very perfect!

3.JavaIME Plug-in installation

After the above operation, sublime Text3 can run the Java code properly, but found the shortcomings of what? We know some Java code, we will definitely import a lot of packages, on Eclipse, just press CTRL + SHIFT + O to help us, but what to do here?

So we have to install a plugin--javaime plugin

Operation:

Preferences–> Package Control –> Add Repository , and then add the content: Https://github.com/tushortz/JavaIME.

After the above steps are completed:

Preferences–> Package Control –>Install Package,然后搜索JavaIME,点击它安装,安装完成过后,重新软件,然后我们就会发现代码可以自动提示和导包提示了。

Demonstrate:

sublime-Configuring the Java environment on the sublime Text3

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.