Execute Java from Sublime Text Editor

  1. Open Sublime Text Editor.
  2. Go to Tools > Build System > New Build System.
  3. Type the following code:
    "cmd": ["javac", "$file_name","&&","start","cmd","/k","java", "$file_base_name"],
    "path":"C:\\Program Files (x86)\\Java\\jdk1.8.0_171\\bin",
    "shell": true

    Make sure that you replace the path of the bin folder according to your Java installation.
    Also, add extra backslashes wherever necessary.
  4. Save it as Java.sublime-build under Sublime Text 3 > Packages > User folder.
  5. Go to Tools > Build System. Select Java from the menu.
  6. Now type a new Java program and execute it by pressing Ctrl + B.

2 thoughts on “Execute Java from Sublime Text Editor

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.