How to configure Java in Sublime Text 3


Hello and welcome back! Today we will install Java Development Kit and we will build the most common application in the world (we will write „Hello World” on the screen). Also, we will use Sublime Text 3 as our IDE.

Installing Sublime Text 3

1. We enter on Sublime Text – Download and select the proper version. If we have a 32-bit system we download „Windows”, otherwise we download „Windows 64-bit”.

2. After we download the right version, we will install the program, following the usual instructions.

Installing Java Development Kit (Java JDK)

1. We enter on Java SE Development Kit Downloads and do exactly as Sublime Text 3, we select the proper version for our system. Windows x86 (for 32-bit) or Windows x64. Don’t forget to tick the „Accept License Agreement” box before downloading the program!

2. We install the version downloaded before.

Setting JAVA_HOME variable

3. Now we must add JAVA_HOME variable, because Windows must know where we installed Java. The first step is to find jdk folder, usually the folder is in

C:\Program Files\Java\jre1.x.x_xxx

4. Depending on our Operating System, we enter:

  • Windows 7: Right click on My Computer, select Properties, then Advanced
  • Windows 8/8.1/10: Enter in Control Panel, select System, then Advanced System Settings

We will see a button called „Enviroment Variables…” and we must click on it.

5. Under System Variables we press on New… (exactly as below)

6. In the new dialog, we write:

Variable name: JAVA_HOME
Variable value: C:\Program Files\Java\jdk1.8.0_101

The Variable value field is the location that we found in step 3.

We press OK and the JAVA_HOME variable is now registered.

Configuring Sublime Text 3 editor

1. We open 7-zip as administrator. If you don’t have 7-zip please install it, because we will need in these steps. Once we opened 7-zip as administrator, we must enter in

C:\Program Files\Sublime Text 3\Packages\

Warning: You must have Sublime Text 3 closed.

2. We search for pachetulJava.sublime-package and open it.

3. Once the archieve is opened, we localize JavaC.sublime-build file and press Edit

4. Delete everything inside and add:

"cmd": ["javac", "$file_name","&&","java", "$file_base_name"],
"file_regex": "^(...?):([0-9]):?([0-9]*)",
"selector": "source.java",
"shell": true

After we add these lines we save the file.

5. We confirm the dialog that appears and close 7-zip.

Our first application in Java

Now, our first application will be a copy-paste one, because this tutorial isn’t quite about Java because this tutorial is only about configuring Java.

1. We create a new file in Sublime Text 3, and copy the following lines:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World");

2. We save the file as „HelloWorld.java” because our class is called „HelloWorld”, and the file must have the same name.

3. Click on Tools > Build System and thick the line with JavaC

4. Now we just press Ctrl+B and enjoy our result!

If you have any questions, don’t forget to ask me on Facebook! Cheers!

Se incarca comentariile...

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More