I wanted to be one front-end developer, but for my job’s need, i have to use php and learn java now. So now, i’m one new javaer. Sometimes, i find it quite funny when coding and loving it day by day.
Since i step into the programer world, i had used notepad++, editplus, e-text editor, gvim, eclipse, but i choose sublime text in the end, i find it awesome! Easy to use and easy to custom your own plugin.
Today i want to tell you how do i combine my sublime text with java’s needs, that is compile and run your java code inside sublime text.
Here is a HelloWorld.java program:
|
1 2 3 4 5 6 |
public class HelloWorld
{
public static void main(String[] args) {
System.out.println("Hello World!");
}
} |
In sublime text you can use ctrl+B to compile the program, for the reason of new to java and the programs are simple, son i want to run it in the right while.
The ultimate solution:
Preference -> Browser packages, find the file JavaC.sublime-build, the javac command executed in sublime text is wrote in this file.
|
1 2 3 4 5 |
{
"cmd": ["javac", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java"
} |
We can modify it, and let it run the program after compile.
|
1 2 3 4 5 6 |
{
"cmd": ["javac", "$file_name","&&","java", "$file_base_name"],
"working_dir": "${project_path:${folder}}",
"selector": "source.java",
"shell": true
} |
I think you will understand the code rightly. After do this, when you use ctrl+B, the result will be:

Here i want to tell you another skill of use sublime text, you can also use the editor to update your changes in the run time. Plugin name: FTPsync







Brilliant,but I think niche software or not in comparison with IDE, for example,eclipse.
Hello, Can you help me? I’m new in Sublime Text 2 and I don’t know how to compile. I followed your steps and the result was:
‘javac’ is not recognized as an internal or external command,
operable program or batch file.
[Finished in 0.0s with exit code 1]
Never mind, just now, it worked!! But thank you so much
how did you solve it?