Compiling and Running Java Code in Sublime Text 2

前端 未结 19 2812
执念已碎
执念已碎 2020-11-28 01:20

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

19条回答
  •  被撕碎了的回忆
    2020-11-28 01:58

    The Build System JavaC works like a charm but fails when you want to give input from stdin in Sublime-text. But you can edit the build system to make it receive input from user. This is the modified JavaC build I'm using on Ubuntu 18.04 LTS. You can edit the build System or create a new build system.

    To Create a new build system.

    • Go to Tools>>Build System>>New Build System.
    • Copy Paste the Below code and File>>Save.

      {

      "shell_cmd": "javac \"$file\"",
      "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
      "selector": "source.java",
      "variants": 
      [
          {
              "shell_cmd":"bash -c \"javac $file\" && gnome-terminal -- bash -c \"java $file_base_name ;read\"", 
              "name": "Run"
          }
      
      ]    
      

      }

    To Edit the existing Java C build file

    • Follow the steps https://stackoverflow.com/a/23790095/10847305
    • Copy-Paste "variants" from this build system.

提交回复
热议问题