Compiling and Running Java Code in Sublime Text 2

前端 未结 19 2819
执念已碎
执念已碎 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 02:18

    {
    "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.

提交回复
热议问题