Of course! Using Sublime Text for Java development is a very popular and efficient setup, especially for those who love a fast, lightweight, and highly customizable editor.

Here’s a comprehensive guide covering everything you need to know, from basic setup to advanced workflows.
Why Use Sublime Text for Java?
- Speed: It's incredibly fast and responsive, even with large projects.
- Lightweight: It has a low memory footprint compared to full-fledged IDEs like IntelliJ or Eclipse.
- Customizability: Every aspect of the editor, from keybindings to the UI, can be tailored to your liking.
- Powerful Search & Navigation: "Goto Anything" (
Ctrl+P) and "Goto Definition" are game-changers for quickly navigating code. - Free to Evaluate: It has a fully functional unlimited evaluation period (though you're encouraged to buy a license if you continue to use it).
Part 1: Installation and Setup
Install Sublime Text
If you haven't already, download and install Sublime Text from the official website.
Install the Java Development Kit (JDK)
Sublime Text doesn't compile Java code itself; it needs the JDK installed on your system to do so.
- Windows: Download from Oracle or use a package manager like Chocolatey (
choco install openjdk). - macOS: Use Homebrew (
brew install openjdk) or download from Oracle. - Linux (Debian/Ubuntu):
sudo apt update && sudo apt install openjdk-17-jdk
After installation, verify it's working by opening your terminal and running:

java -version javac -version
You should see the version numbers for both the Java runtime (java) and the compiler (javac).
Install the Java Compiler Plugin (The "Magic")
This is the most important step. We'll use a plugin called "SublimeJavaCompiler". It allows you to compile and run Java files directly from Sublime Text with a single key press.
Installation via Package Control (Recommended):
- Install Package Control: If you don't have it, open the Sublime Text console (
Ctrl+`` orView > Show Console`) and paste the following Python code, then press Enter. It will install Package Control.import urllib.request,os,hashlib; h = '7181a2d3e91f20035d7c66b041c9eea9' + 'bc33e8e8d40c6cfa0e3722e042f97ab0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by) - Restart Sublime Text.
- Install the Plugin: Press
Ctrl+Shift+P(orCmd+Shift+Pon Mac) to open the Command Palette. TypeInstall Packageand select it. Then, typeJava Compilerand select "SublimeJavaCompiler" by "guillermooo".
Part 2: Basic Workflow
Create a New Java File
- Open Sublime Text.
- Go to
File > New File. - Save the file with a
.javaextension (e.g.,HelloWorld.java). - Sublime Text will likely ask if you want to set the syntax. Choose Java.
Write Your First Java Program
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello from Sublime Text!");
}
}
Compile and Run
With the SublimeJavaCompiler plugin, this is incredibly simple.

- Compile: Press
Ctrl+B. The output pane at the bottom will show the compilation result. If successful, aHelloWorld.classfile will be created in the same directory. - Run: Press
Ctrl+Shift+B. The plugin will first compile (if needed) and then run the code, showing the output directly in the Sublime Text console.
You should see:
Hello from Sublime Text!
Part 3: Essential Plugins for a Better Java Experience
Sublime Text's real power comes from its plugins. Here are the must-haves for a professional Java workflow.
LSP (Language Server Protocol)
This is the most important plugin you can install. It brings IDE-like features (code completion, error checking, "Go to Definition," etc.) to Sublime Text.
- Installation: Use Package Control (
Ctrl+Shift+P>Install Package>LSP). - Installation: After installing LSP, you need to install a Java language server. The most popular one is Eclipse JDT Language Server. Install it via Package Control as well (
Install Package>LSP-jdtls). - Configuration: LSP should work automatically for
.javafiles once both are installed. You can verify it's working by typing inside a method—you should see code completion pop up.
SublimeLinter
This plugin provides a code linting framework, which helps you spot errors and style issues as you type.
- Installation: Install via Package Control (
SublimeLinter). - Installation: Now, install a linter for Java. The best one is Checkstyle. Install it via Package Control (
SublimeLinter-contrib-checkstyle). - Configuration: You might need to configure Checkstyle to use a specific ruleset (e.g., Google's). This is more advanced, but SublimeLinter will work out of the box with basic checks.
SideBarEnhancements
This is a must-have for any Sublime Text user. It dramatically enhances the functionality of the file sidebar.
- Installation: Install via Package Control (
SideBarEnhancements). - Features: Now you can right-click on a file or folder in the sidebar to:
- New File: Create new files/folders instantly.
- Move, Copy, Rename: Easily manage files.
- Open in Browser: Great for web projects, but useful for other things too.
Part 4: Advanced Configuration (Optional but Recommended)
Create a Build System for Projects
The default Ctrl+Shift+B is great for single files, but for projects, you might want more control. You can create custom build systems.
-
Go to
Tools > Build System > New Build System.... -
A new file will open. Replace the contents with this example for a standard Java project:
{ "cmd": ["javac", "$file", "&&", "java", "$file_base_name"], "file_regex": "^(...*?):([0-9]+):?([0-9]+)?:? (.*)$", "selector": "source.java", "shell": true, "working_dir": "${file_path}", "encoding": "utf-8", "env": {"JAVA_HOME": "/path/to/your/jdk"} // Optional: Set your JAVA_HOME if needed }"cmd": This is the command to run. It first compiles (javac) the current file ($file) and then runs (java) the compiled class ($file_base_name)."working_dir": Sets the directory where the command will run (useful for multi-file projects).
-
Save the file with a memorable name, like
JavaProject.sublime-build. It will be automatically added to the build system list.
Configure Project-Specific Settings
For a multi-file Java project, you can tell Sublime Text where to find your source files.
-
Go to
Project > Edit Project. -
A JSON file will open. Add a
folderskey to specify your source directory.{ "folders": [ { "path": ".", // The current folder "folder_exclude_patterns": ["build", "target", ".git"] // Exclude common build and version control folders } ], "settings": { "lsp_jdtls_workspace": "${project_path}/.metadata/.plugins/org.eclipse.core.resources/.projects" // LSP workspace setting for Java projects } }This tells LSP and other tools that your project's root is here and helps them ignore unnecessary folders.
Sublime Text vs. IntelliJ IDEA: A Quick Comparison
| Feature | Sublime Text | IntelliJ IDEA |
|---|---|---|
| Speed | Extremely fast and lightweight. | Slower to start, can be heavy on large projects. |
| Learning Curve | Low for basic use, high for advanced customization. | Steeper learning curve due to sheer number of features. |
| Features | Core editor + plugins. Requires manual setup. | All-in-one IDE. Refactoring, debugging, testing are out-of-the-box. |
| Refactoring | Possible with plugins (e.g., LSP), but limited. | Industry-leading. Renaming, extracting methods, etc., are effortless. |
| Debugging | Not available. Must use external tools or command-line debuggers. | Excellent, integrated debugger with breakpoints, watches, etc. |
| Best For | • Quick scripts • Small to medium projects • Developers who love speed and customization • Writing code in multiple languages |
• Large, enterprise-level projects • Teams requiring robust tooling • Developers who want an "all-in-one" solution |
Conclusion
Using Sublime Text for Java is a fantastic choice if you value speed and a clean, distraction-free environment. While it requires a bit more initial setup than a full IDE like IntelliJ, the plugins available today (especially LSP) can bring you 80-90% of the way there in terms of core development features.
For many developers, Sublime Text provides the perfect balance between a lightweight text editor and a powerful IDE.
