在 Sublime 3 中构建 Java [英] Java Build in Sublime 3
问题描述
我正在尝试建立一个构建,以便我可以在 sublime 3 中编译和运行 Java.我的构建系统不工作.
I'm trying to set up a build so that I can compile and run Java in sublime 3. My build system isn't working.
"cmd": "java ${file_name} && java ${file_base_name}",
"file_regex": "^[ ]file \"(...?)\", line ([0-9]*)",
"path":"C:\\ProgramData\\Oracle\\Java\\javapath\\java.exe",
"selector": "source.java",
"shell":true
我将此构建保存到我的包中,它出现在构建菜单中,但是当我尝试运行它时,它说没有构建工作.
I have this build saved to my packages and it appears in the build menu, but when I try and run it, it says that there is no build working.
推荐答案
请阅读 构建系统文档,了解有关如何构建 .sublime-build
文件的信息."cmd"
和 "path"
是列表,而不是字符串,因此这可能是您收到错误的原因之一.正如我在评论中提到的,另一个原因是您正在尝试使用 java
而不是 javac
编译您的 .java
文件.最后,您的 "path"
不正确 —它应该指向目录列表,而不是文件.这可能更适合您:
Please read the build system documentation for information on how to structure .sublime-build
files. "cmd"
and "path"
are lists, not strings, so that's one reason you may be getting an error. Another reason, as I mentioned in the comments, is that you are trying to compile your .java
file with java
instead of javac
. Finally, your "path"
is incorrect — it should point to a list of directories, not files. This may work better for you:
{
"cmd": ["javac", "${file_name}", "&&", "java", "${file_base_name}"],
"file_regex": "^[ ]file \"(...?)\", line ([0-9]*)",
"path": ["C:\\ProgramData\\Oracle\\Java\\javapath"],
"selector": "source.java",
"shell": true
}
这篇关于在 Sublime 3 中构建 Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!