I am trying to compile and run Java code in Sublime Text 2. Don\'t just tell me to do it manually in the Command Prompt. Can anyone tell me how?
Btw, I am on Windows
{
"shell_cmd": "javac -Xlint \"${file}\"",
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"working_dir": "${file_path}",
"selector": "source.java",
"variants": [
{ "shell_cmd":"javac -Xlint \"${file}\" && java $file_base_name < input.txt > output.txt",
"name": "Run"
}
]
}
save this sublime build and run the program with ctrl + shift + B with run variant.Without run variant it will just create .class file but wont run it.
This build will read the input from input.txt and print the output in output.txt.
Note: both input.txt and output.txt must be present in the same working directory as your .java file.