简体   繁体   中英

How to compile JAVA on Sublime text 2 using Mac OS X?

我在互联网上四处寻找,却发现非常复杂的结果,但现在不确定该怎么做。

Sublime text 2 has builtin Java support:

在此处输入图片说明

Which means that once you have opened the Java source, all you have to do is press command+B


What you described in the comments is a bit different - you should update your post with this information!

Devin posted a gist solution here :

You should add a new build-system by going to the menu:

Tools --> Build System --> New Build System

and add the following json and save it as "Java.sublime-build" into the default directory (which is something like: ~/Library/Application Support/Sublime Text 2/Packages/User/ ):

{
    "cmd": ["javac", "$file_name"],
    "cmd": ["java", "$file_base_name"],
    "working_dir": "${project_path:${folder}}",
    "selector": "source.java"
}

Next time you want to compile & run use "Java.sublime-build" from your build-systems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM