# Building Java applications inside Emacs with JDEE

First of all, I think Eclipse is a great IDE. There are a ton of features that work really well in Eclipse: intellisense, auto-compilation, and hotswap debugging. It handles your project and classpath pretty well too… But the more I get used to Emacs the less I can stand typing in an non-Emacs setup. Eclipse even has key binding support for Emacs mode, but it’s just not the same. Plus, it occupies a tremendous amount of real-estate as seen below.

So I’m trying Java within Emacs with JDEE. At the moment, I can’t get it to be an Eclipse replacement and I’m not sure it supports completions like Eclipse does. But when I started typing I forgot I had auto-complete mode on! While it may not know the scope of a class, it saves a lot of time with quick tab completion of long Java variable and class names. Intellisense and auto-complete mode are two different tools, but I’m starting to think I’d rather have the auto-complete over Intellisense. Also, as I’ve been using YASnippet more and more, I can quickly add custom snippets to expand code. Eclipse does have some of this, namely a nice `try / catch` like snippet. But imagine being able to have that code expansion on anything you wanted… that’s YASnippet!

But to get it to work with Emacs 24, there is some annoying configuration. I found an obscure forum post that details the instructions, which seem to get JDEE up and running. After some manual project configuration by customizing some variables as outlined in the user’s guide, I was able to get my project built and running.  Yeah yeah, Eclipse automatically handles the classpath variable, I know.

Honestly, this is a lot of pain to go through and I don’t recommend it unless you are already an Emacs user. But, once one does get it finally working, I think the benefits of staying in Emacs outweigh the context switch of using Eclipse. At least for small projects. For large projects with complex dependencies and a complicated build process, I’m not sure about JDEE, but for small projects, like this Othello game AI I’m working on, it’s fine.

So this weekend I’ll be improving my Othello AI and studying for my AI midterm.  (All things I should be doing instead of trying to get Emacs to work well with Java… 🙂 )

# Emacs and PostgreSQL

One of the nice things about going to grad school, is that I really get to refine my Emacs fu.  I’m taking this database class where we are using PostgreSQL and I’m using Emacs’ minor sql modes and I’m very impressed.  Now, I’m no emacs knight, nor do I have the Emacs-fu of the emacs rocks guy, but like any good student of zen, I’m maintaining a beginner’s mind (which is pretty easy to do with Emacs since it does pretty much everything).

So, with the setup in the screenshot and working in the SQL minor mode, once I’ve written my query, I can shoot it over to the SQL Interpreter with at quick ^C-^C, which then runs the query and outputs the results, meanwhile the point stays right where I left it!  Logging into the database is easy by firing off $\texttt{M-x sql-postgres}$ and entering your credentials.  This mode is even more essential when SSHing in the department CS machines, where I then must connect to a remote DB server, only accessible from another CS department machine.  Since this all is done in Emacs, in one screen, I have a complete SQL IDE, which is great.

This may seem a bit archaic to some to still use Emacs when there are other, more intuitive interfaces out there.  But even those vim users can appreciate that there is much to be had for learning the same tool and using it everywhere.  Admittedly, in this area I need some attention since I’m writing this post now in WordPress’ online editor, and I actually like Eclipse’s intellisense, and I’m tied to a proprietary editor at my day job.  But besides WordPress, Eclipse, Mail, roads, public order and sanitation, what has Emacs done for us!?!  Brought peace?!

Areas where I think I can realistically incorporate Emacs:

1. First draft of blog posts.  100% integration looks a bit wonky with WordPress and I’m still in that baby-blogger phase where I bounce back and forth from the preview to the  edit screen and make tweeks.  But the main draft can (and should) be authored from Emacs.
2. Code more in Emacs.  For any of the scripting languages this is easy.  For C and C++, this isn’t too hard for me either since I never really grew up on Visual Studios, but for Java… Typing $\texttt{this.}$ and then seeing a list of options is very handy.  Except when I had this kick where I was over-using reflection, then Eclipse can’t really keep up…
3. Email.  I checked out gnus the other day and while I see how an Emacs only mail client can be done, with so much inline html these days, I’m not sure if its worth it.  But I’m poking a stick at this bear and I’ll probably come back to it.
4. $\LaTeX$.  I love $\LaTeX$.  Once I learned WordPress supported this, I was even more addicted to WordPress.  My résumé, presentations, papers, letters (when I must actually print one out), are all done in lovable $\LaTeX$.  If you find yourself cursing at M\$ Word, take the red pill my friend.  And then you’ll start cursing weird compile errors, but worry about that after you take the pill…  Many thanks to Brent over at The Math Less Traveled for showing me this!

Well, that’ll keep me busy for a while 🙂