Run Java With Input in Sublime Text 3/4

Xavier
1 min readMay 28, 2021
  1. Install Package Control
  • Open command palette: Win/Linux: ctrl + shift + p, Mac: cmd + shift + p
  • Type: “install package control”, press enter.

2. Install Terminus

  • Open command palette: Win/Linux: ctrl + shift + p, Mac: cmd + shift + p
  • Type: “package control: install package”, press enter.
  • Type: “terminus”, press enter.

3. Create a new build system

  • Open command palette: Win/Linux: ctrl + shift + p, Mac: cmd + shift + p
  • Type: “build new build system”, press enter.
  • Delete everything and copy & paste:

{
“target”: “terminus_exec”,
“cancel”: “terminus_cancel_build”,
“shell_cmd”: “javac $file && java $file_base_name”,
“working_dir”: “$file_path”
}

  • Ctrl + s(win) or cmd + s(mac)to save the .sublime-build file to create a new build system. (For example save it as RunJava.sublime-build)

4. Run Java In Sublime Text 3/4

  • Tools — Build System — RunJava
  • Write some Java code and save it.
  • Ctrl + b(win), cmd + b(mac) to compile and run Java file.

5. References:

How to have input Java? — Technical Support — Sublime Forum (sublimetext.com)

Compile and Run Java Programs in Sublime Text in Linux — GeeksforGeeks

--

--