Building a Java dev environment with Eclim and Vim on OSX
As anyone who has done Java development will tell you, doing it without a java-specific IDE can suck. So, enter Eclipse and Netbeans, probably the 2 biggest java IDEs out there (among many).
But I don’t want to use Eclipse or Netbeans. I want to use Vim.
Enter Eclim, which is a way to use Eclipse’s wide array of features in Vim. Check out the site, it gives a better idea of how it’s used than I can. Unfortunately, only binaries for Linux and Windows are available, so we’re going to have to do this the hard way on OSX. Let’s get started.
The first thing we’ll need is Eclipse. I’m using Eclipse 3.4.3, which I downloaded, uncompressed and moved to /Applications/Eclipse (so the full path is /Applications/Eclipse/Eclipse.app, this is important for later).
Next, let’s grab Eclim from the sourceforge site, the tar.gz file (not the .exe or the .sh). I’m using Eclim 1.4.7. Untar and wait a second, we’ll need to grab something before we can build Eclim.
Eclim requires Ant 1.7.1 in order to build (OSX ships with Ant 1.7.0 instead), so download the Ant 1.7.1 binary for OSX from Apache’s sites, untar, but don’t worry about installing it.
Lastly, grab the latest Vim 7.2 tarball from vim.org. Unfortunately, Apple decided not to compile the system vim with ‘sign’ support, so we’ll have to roll our own version of vim.
Now, let’s begin:
First, we’ll need a folder for the vim plugins, which needs to be created manually or Eclim will complain:
[~]% mkdir ~/.vim/eclim
Next, compile the Eclim files from the eclim directory using the ant 1.7.1 binary. In this example I’m only compiling the ant and jdt plugins for Eclim, because the CDT and PDT plugins require other Eclipse libraries, and I only use Eclipse for Java development anyway. Be sure to change your eclipse.home setting if you didn’t put it in the same place as me:
[~/code/eclim_1.4.7]% ../apache-ant-1.7.1/bin/ant -Declipse.home=/Applications/Eclipse/ -Dplugins=ant,jdt
The Ant command will build and install the files at the same time, so afterwards you shouldn’t have to manually install any Vim or Eclim files.
Next, we need to recompile Vim with sign support, here’s how I compiled my version, make sure to keep the –enable-gui=no and –without-x options, or else vim will start X11 every time you run in:
[~/code/vim72]% ./configure --enable-gui=no --without-x --with-features=huge --prefix=/usr/local
[~/code/vim72]% make
[~/code/vim72]% sudo make install
Switch out the system vim for the one we just created:
[~/code/vim72]% sudo mv /usr/bin/vim /usr/bin/vim.mac.old
We’ll need some way to start the Eclim daemon that was installed, and eclimd doesn’t care for symlinks, so I created an alias in my .zshrc (or .bashrc if you use bash):
alias eclimd='/Applications/Eclipse/eclimd'
Next, we need to fix the /Applications/Eclipse/eclimd shell script, because Apple’s readlink command does NOT support the -f option, so change this line:
RESOLVED=`readlink -f "$0"`
To this:
RESOLVED=`readlink "$0"`
Now, after all that, start up eclimd:
[~]% eclimd
You should see something like this (screenshot):
Alrighty, now we can start Vim, give these two commands a try to see if eclimd communication can be established:
(Will output the Eclipse and Eclim version if everything is working)ingEclim
:EclimValidate(You should get: “Result: OK, required settings are valid.”)
Hopefully you were able to get a connection. If not, leave a comment and I’ll try to help you out
Okay, so it’s set up, congratulations! Now what can you do with it, well I suggest checking out Eclim’s Java page to see what you can do, but the features I end up using the most are validation, completion and correction. Validation will validate the Java file every time you save it, marking the lines where errors in compilation occur. See the following screenshot (notice the red “>>” markers):
Completion (through Ctrl+x-Ctrl+u) gives you the awesome completion that Eclipse has, like so:
Correction allows you to go to a line with an error marker, and have Eclipse suggestion a fix, just like it would in the IDE, to apply the fix, put the cursor on the red line and hit Enter:
Now go read all the documentation to see the neat things you can do
I usually end up doing the actual project management (adding files, adding external jars to the classpath, generating ant build.xml files and other gui-type stuff) from Eclipse still, but for the actual coding, I’m all about Vim.
Oh yea, one other thing I should mention, so Vim settings for your .vimrc that are really helpful for this:
If you use Supertab (tab-completion with tab instead of Ctrl+x-Ctrl+u):
" Supertab settings
" supertab + eclim == java win
let g:SuperTabDefaultCompletionTypeDiscovery = [
\ "&completefunc:<c-x><c-u>",
\ "&omnifunc:<c-x><c-o>",
\ ]
let g:SuperTabLongestHighlight = 1
And some Eclim .vimrc settings that I use:
" Eclim settings
" ,i imports whatever is needed for current line
nnoremap <silent> <LocalLeader>i :JavaImport<cr>
" ,d opens javadoc for statement in browser
nnoremap <silent> <LocalLeader>d :JavaDocSearch -x declarations<cr>
" ,<enter> searches context for statement
nnoremap <silent> <LocalLeader><cr> :JavaSearchContext<cr>
" ,jv validates current java file
nnoremap <silent> <LocalLeader>jv :Validate<cr>
" ,jc shows corrections for the current line of java
nnoremap <silent> <LocalLeader>jc :JavaCorrect<cr>
" 'open' on OSX will open the url in the default browser without issue
let g:EclimBrowser='open'
Enjoy!
Why don’t Christian writers license their work with Creative Commons?
Alright, non-technical, semi-religious post. If all you care about is technical stuff, skip reading this.
So I’ve had this nagging feeling every time I read a Christian book (other than the Bible), something that the author intended to inspire, impart knowledge, hold accountability and so forth, of why would the author want me to pay to hear this? I don’t understand why a Christian author, intentionally writing a book meant for a Christian audience, licenses his/her work in such a way that the book will only reach people who spend an amount set by the publisher and/or author, instead of a broader audience.
Now, let me set something straight. I haven’t written a book, I don’t know the entire negotiation process that goes on between the publisher and author. What kind of deals are brokered? I don’t know. Is there a secret ritual or rite of passage that occurs before given the go-ahead to write a book? I don’t know.
So where does that leave me? Empty speculation and argumentation about something I don’t fully understand the entire workings of. Welcome to the internet.
Let’s pretend you’re an author.
You have an awesome idea, inspiration touched you and you feel compelled to share that inspiration with the world. So, what better way than a book right? I mean, people still read nowadays right?
So you write, you write during your free time about something you’re passionate about, and (assuming you’re writing a Christian book, which is what this post is about) you want to share it with as many Christians as possible. So you sign on with a publisher to distribute, print and market the book. Let’s say your book ends up costing $14.95, which seems in line with where book prices for this sort of book are.
Now comes the hard decision. Will you as the author sacrifice your original intent to spread the word of your book to as many people as possible by having a barrier to (readership) entry of $14.95?
Because that’s what I feel like Christian authors are doing. Maybe they aren’t aware there is an alternative?
Take, for example, Shane Claiborne‘s book: The Irresistible Revolution. This is a book that, while it has its faults, I think would be beneficial for all Christians to read, so why the cost of $10.19 (on Amazon) for something that should be a work of service to the Christian community? Shane has a very anti-consumerist message in a lot of his books, so why even charge for the book at all? (I understand charging for a hard copy of the book because of printing fees, etc, but why not just post it free online as a PDF?) I know that Shane is not a professional, full-time author, so the money is not going to support him. Is the money going to charity? Great! There is still a win-win situation for both parties: licensing the book under Creative Commons.
There a few different licenses to choose from. Shane could go with Attribution Non-Commercial No Derivatives for the license, which would mean he would be attributed as author of the work, someone else could not sell it and no derivatives could be made of it. However, it could be freely distributed and copied, which is exactly the point of writing a Christian book to me.
This doesn’t preclude making money (if so desired, for charity or supporting the author) from the book. Creative Commons allows for dual-licensing a work, so Shane could enter into a revenue generating license (i.e., with Zondervan, the current publisher of Irresistible Revolution), while preserving the disseminating power of a CC license. This of course assumes Zondervan would be up for that idea, I hope they would.
It’s not like it hasn’t been done. Look at authors like Cory Doctorow, whose novels are both published by Tor and released with CC license on his website, to encourage sharing of his works. Take “Someone Comes to Town, Someone Leaves Town” for example, I purchased a copy at Barnes & Nobles (for ~$10 I think), but the entire book is also available to anyone who wants to download it from Doctorow’s site.
The point is, writing a book meant to be widespread can be assisted by licensing under Creative Commons. And, since one of the points of being a Christian author is to reach a large Christian audience with your message, I have to ask, why don’t more Christian authors release their books under CC licenses and then dual-license with another license? Did we focus on the wrong goal of writing a book for Christian audiences (by a Christian), that is, making money?
Shouldn’t we be focusing on the message and not the monetary gain?
NOTE: If you leave a comment, give me a day or so to reply to you, I normally think about the comment for a while before responding, I haven’t forgotten about your comment.




