Wednesday, July 30, 2014

Sublime Text: Compile and Run Java class within Sublime Text in Windows

To compile and run a Java class using a single command Ctrl + B within Sublime Text 2 or Sublime Text 3 beta in Windows based systems, update the Sublime Text file located at "<User Directory>\AppData\Roaming\Sublime Text 2\Packages\Java\Java.sublime-build" with the below script. Create folder/file if you don't have one. Also change Java bin directory to yours.


"cmd": ["javac", "$file_name", "&&", "java", "$file_base_name"], 
"shell": true, 
"path": "C:\\Program Files (x86)\\Java\\jdk1.8.0_05\\bin", 
"file_regex": "^(...*?):([0-9]*):?([0-9]*)", 
"selector": "source.java" 
}

Here's I believe what you are expecting:


















Change your Sublime Text Build System to Java if necessary.




Note: If you are using portable version of Sublime Text, I am guessing you will want to put this under the Sublime Text installation directory e.g "Sublime Text 2\Packages\Java\Java.sublime-build". Again you may have to create any folder/file if it does not exist.

No comments:

Post a Comment