Compiling and Running Java Code in Sublime Text 2

前端 未结 19 2816
执念已碎
执念已碎 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:57

    This version of JavaC.sublime-build which is edited from vijay's answer works for me on both Windows 7 and Mac for Sublime Text 3.

    I edited it so Ctrl+b or command+b is sufficient for both build + run.

    {
    "shell_cmd": "javac -Xlint $file && java $file_base_name",
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
    "selector": "source.java",
    "shell": true
    }
    

    '&&' ensures that the second part runs only when first part succeeds ie only when the class file is generated. You can find more related info here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true

提交回复
热议问题