Skip to content →

Sublime Text 3 For Java

Sublime Text is an amazing software. To start, it is a clean, efficient, functional, and fast code editor. Not only does it have incredible built-in features, but it has support for plugins, snippets, and many other things.

Recently I’ve taken a Java course in my University, Most of us use Eclipse (Eclipse IDE is awesome for Java), In case, All of my Classmates were using Eclipse, Unfortunately I did not like its performance and UI. So I did look forward to Write, Compile and Run Java on my Favorite Code editor Sublime Text 3. Finally Found a way out. I know there have already been many articles like this, but Thought it would be good to have all the information online. In this article, We’ll be diving into How to Build and Run Java Codes on Sublime Text 3. There are Two steps to be followed.

Step 01:
By default The location of JDK isn’t always updated or correct .So Firstly, We’ll have to update the location of JDK in Windows Environment Variables. To do that  follow the instructions below:

  • Go to “My Computer” then “System Properties” and click on “Advanced System Settings” from Sidebar
  • Click On “Environment Variables”
  • A window titled “Environment Variables” Should Come up
    • Click TEMP on the top area.
    • Scroll a little down and find Path.
    • Select Path and click Edit.
    • Paste this location at the end of text area.
    • If You are using different version of JDK You should replace this by location of bin folder of Your JDK. Don’t forget to add a semicolon before Location.
    • ;C:\Program Files\Java\jdk1.8.0_45\bin
    • Make sure to OK out of both windows
    • Okay, Great. Now Proceed to 2nd  Step

Step 02:

  • Now create a file named JavaC.sublime-build Remember it’s extension name is .sublime-build.
  • Copy this code snippet below and paste into the file You’ve just created and move it to C:\Users\"Your Username"\AppData\Roaming\Sublime Text 3\Packages\User
         "shell_cmd": "javac -Xlint \"${file}\"",
         "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
         "working_dir": "${file_path}",
         "selector": "",
                   "name": "Run",
                   "shell_cmd": "java \"${file_base_name}\""
  • Now on write java on Sublime text and press Ctrl-B to Compile and Ctrl-Shift-B to Run.

There is an another way that you can Follow. I didn’t try this though.

Published in Java Sublime Text Text-Editor


Leave a Reply

Your email address will not be published. Required fields are marked *