Created
January 26, 2015 20:02
-
-
Save mickeypash/ee1fd034733e8e46785b to your computer and use it in GitHub Desktop.
Run and Compile Java from SublimeText 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cmd": ["javac", "-Xlint", "$file"], | |
"file_regex": "^(...*?):([0-9]*):?([0-9]*)", | |
"selector": "source.java", | |
"variants": [ | |
{ "cmd": ["javac", "-Xlint", "$file"], | |
"file_regex": "^(...*?):([0-9]*):?([0-9]*)", | |
"selector": "source.java", | |
"name": "Java Lintter" | |
}, | |
{ "cmd": ["java", "$file_base_name"], | |
"name": "Run Java" | |
} | |
] | |
} |
The original:
{
"cmd": ["javac", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java"
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What this does is that it creates variants to the regular build command (ctrl+b). With ctrl+b you will still be able to compile your code. If you do shift+ctrl+b the first variant will be executed, which in this case is javac with the -Xlint option. The second and final variant is the java command itself. you can place this as your first variant and shift+ctrl+b will actually execute the java code.
Also, notice that each variant as a "name". This basically allows this specific "build" option to show up in the shift+ctrl+p option. So using this configuration, you can simply do shift+ctrl+p and type "Run Java" and hit enter, and your code will execute.
Thanks to @vijay