Solve how to compile and run Java in SublimeText 2

I found a lot of people discussing about how to compile and run the results of Java (single file) in SublimeText 2. Well, after trying another alternative and failing, finally I found how to make it works. It’s easy actualy, all you need are:

1. Edit SublimeText2 Java Build

1
~/.config/sublime-text-2/Packages/Java/JavaC.sublime-build


2. Configure SublimeText 2 to run Java and showing results after compile

1
2
3
4
5
{
        "cmd": ["sh", "-c", "javac $file_base_name.java && java $file_base_name"],
        "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
        "selector": "source.java"
}

3. Close and re-open your SublimeText

4. Set build into Java environment (or auto)

5. Test build and Run Java by CTRL + B

6. You should see Java results appear in SublimeText Console

Comments

  1. Your post, Solve how to compile and run Java in SublimeText 2 by Java Software Engineer and Programmer, is really well written and insightful. Glad I found your website, warm regards!

    Reply
  2. Hi! I’ve been following your blog for a long time now and finally got the courage to go ahead and give you a shout out from Lubbock Tx! Just wanted to mention keep up the fantastic work!

    Reply
  3. Hello! I could have sworn I’ve been to this website before but after browsing through some of the post I realized it’s new to me. Anyhow, I’m definitely delighted I found it and I’ll be book-marking and checking back often!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>