javac program.java
and java program
from a console from within Sublime Text.Preferences
menu, select Browse Packages...
and navigate to the Packages/Java
folder, and open the JavaC.sublime-build
file:javac
is in the PATH
used by Sublime, you may need to edit it to fit your system's setup. You can run this build system by first saving your .java
file, then selecting either Tools -> Build System -> JavaC
, or Tools -> Build System -> Automatic
, then hitting CtrlB (⌘B on Mac)..class
file, modify JavaC.sublime-build
to the following:Run
variant of the build system. The 'working_dir': '${project_path:${file_path}}'
line executes the build from the directory containing your .sublime-project
file, if you don't have one it defaults to the directory containing your .java
source. 'shell': true
runs the 'cmd'
through the shell, whether it's cmd.exe
, bash
, or whatever you choose. Otherwise, it just outputs through the Sublime console. The 'env'
dictionary allows you to add Key:value pairs of environment variables you might want to set just for the build session. It can be in the 'Variants'
section or the main one, depending on your needs. Packages
directory's subfolders and check out any .sublime-build
files you find for ideas - their names are listed under Tools -> Build System
(i.e., the 'Python' build system is found in Packages/Python/Python.sublime-build
).subprocess.Popen()
, I prefer to use the fantastic SublimeREPL
plugin (available through Package Control) along with IPython
. There are a bunch of dependencies, but easy_install ipython[all]
should take care of most of that for you, as would installing through a package manager like MacPorts
, yum
, apt-get
, etc. For Windows, precompiled binaries are available from Christoph Gohlke's Python Extension Packages for Windows repository, which includes links to all the required and optional dependencies. Make sure you're using the python.org installation of Python, though.PATH
, and SublimeREPL installed, go to Tools -> SublimeREPL -> Python -> Python - IPython
and you should be up and running momentarily. To execute a shell command, simply prefix it with !
- for example:!cd ..
won't actually change the current working directory, you'll need to run:os
module's Files and Directories functions is very useful here (change the 2
in the URL to a 3
if you're using Python 3) - which brings up another strong point of this system: You can have multiple versions of Python on your system, and not have to depend on the stripped-down version of 2.6 that ships with Sublime Text 2. Save the following to Packages/User/SublimeREPL/config/Python/Main.sublime-menu
and customize for your tastes:SublimeREPL
upgrades from Package Control, and run REPLs with different options, working directories, what have you.