I would like to make a build system in Sublime Text 2 that will compile a Java file, and then run it in a new Terminal (for OS X or Linux) or Command Prompt (for Windows) window.
The reason for this is because Sublime Text 2 doesn't allow users to input anything, so any programs requiring input will spit out an error when running inside Sublime Text 2, like this:
This is what I currently have (I've also tried a batch file), but it simply runs inside Sublime Text 2, as opposed to in a new shell:
Is this possible? If so, please explain, step-by-step (I'm a noob at Sublime Text 2), how to do it; I've already tried posting on the Sublime Text 2 forums, and so far no luck! I'd be inexpressibly grateful. Thanks for your time!
Here's the "polite" (read: short and readable) version of what I did to make this work.
Nutshell (Simplification): compile and run through a shell script in order to get a new window.
Script
cd $1
/usr/bin/javac $2
/usr/X11/bin/xterm -e "/bin/bash -c \"/usr/bin/java $3; echo 'Press ENTER to quit...'; read line\""
JavaC.sublime-build
{
"cmd": ["~/bin/run-java.sh $file_path $file $file_base_name"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"path": "/usr/bin/java",
"selector": "source.java",
"shell": true
}
In real life it's a bit more complex.
All this said, I never really do anything with console input in Java proper; I do it via either a Groovy or JRuby REPL, or allow stubbing of input/output sources/destinations, or… but not in Java, and not from Sublime Text 2–I use an IDE for Java development. Anything else is a waste of my time, even for short, experimental stuff.