About     Search     Feed

Nilesh D Kapadia


Music     Twitter     Github

Getting Subclipse (and JavaHL) to work in Ubuntu Linux

—UPDATE 2: I no longer use JavaHL or Subclipse. I now use the pure-Java SVNKit (formerly known as JavaSVN) and Subversive. See my latest blog on the subject for details.

—UPDATE: The instructions in this entry are no longer necessary in Dapper, as they now have a JavaHL package. Just install “libsvn-javahl” then make sure you add the following to your Eclipse launcher parameters:

-vmargs -Djava.library.path=/usr/lib/jni

Note that the JavaHL library is stored in /usr/lib/jni, which is different than what happens with the custom package I had described in this entry.

Also, see comments below if you are having problems with this. After having problems with JavaSVN, I ended up having to use JavaHL. In Ubuntu (and probably other distros), this takes a bit of effort to set up. Read on for how I made a .deb package for JavaHL.

I recently switched from CVS to SVN for my personal projects. I saw a lot of major open source projects making the switch, so I figured its safe enough. I’m the only user of my repositories, but I occasionally do work on the same projects from multiple computers.

One of the important factors for me is the Eclipse plugin. The CVS support in Eclipse is so excellent that I would have to have something that matches it for the switch to be worth it. And Subclipse may just be good enough to match it.

After some problems getting JavaHL library to work with Subclipse (while I was using Debian sid), I gave up and used the JavaSVN library. It worked fine while I worked on the same computer. When I finally tried working off another computer, and synchronizing the changes back on my Linux machine, things became difficult. The other computer is running Windows and using the JavaHL library (appears to be installed out-of-box). When I went back to my Linux machine (now I had switched to Ubuntu) to synchronize, it would take a very long time to finish the synchronize, and then it would not pick up all the changes I made (they were in the repository, but it was not recognizing them). The problems were bad enough that it became unusable (I was even considering switching back to CVS), so I decide to try to install the JavaHL package.

Unlike Debian sid, Ubuntu doesn’t have a javahl package. So I found this wiki page which helped me figure out how to do it. Some of the information from that page I am quoting here (with some modificatons).

As a normal user, I retrieved the subversion source code:

apt-get source subversion

Entered the subversion directory (I’m using 1.2.0 here)

cd subversion-1.2.0

Edited the file debian/rules and change:

ENABLE_JAVAHL=no

to:

ENABLE_JAVAHL=yes

Search for the string “with-jdk” and make sure it points to your JDK home directory, mine looks like this:

confflags += --enable-javahl --without-jikes --with-jdk=/usr/lib/j2sdk1.5-sun

Now build the package (this will take quite a while):

fakeroot dpkg-buildpackage

If you get an error for missing dependencies, install all the packages it says to install. Also, install “gcc cpp g++” packages if you don’t already have them (I had a fresh system, so I didn’t).

I chose to make a Debian package for this, since if I don’t, I’d probably forget that I copied files into the /usr directory. Now you can either copy the debian/libsvn-javahl directory somewhere or work on it directly. In the libsvn-javahl directory, create a directory called “DEBIAN”:

mkdir libsvn-javahl/DEBIAN

I’m not sure if the following command is necessary, but if you get errors later you may want to try it:

find ./debian -type d | xargs chmod 755

Then created a file libsvn-javahl/DEBIAN/control that looks like this:

Package: libsvn-javahl
Version: 1.2.0
Section: Development
Priority: optional
Architecture: i386
Depends: subversion (>= 1.2.0)
Maintainer: Nilesh Kapadia
Description: javahl library for Subversion

“ldconfig” needs to run after an install, and probably after an uninstall, so I created a file libsvn-javahl/DEBIAN/postinst (for post-install):

#!/bin/sh
set -e
echo "Executing ldconfig"
ldconfig

and libsvn-javahl/DEBIAN/postrm (for post-remove):

#!/bin/sh
set -e
echo "Executing ldconfig"
ldconfig

Now we are ready to build the Debian package:

dpkg-deb --build libsvn-javahl

Now, as root (everything up to now was as a normal user), install the package:

dpkg -i libsvn-javahl.deb

Add the following to the Eclipse command line in your launcher:

-vmargs -Djava.library.path=/usr/lib

Now run Eclipse and switch the Subclipse setting to JavaHL (if its not set already). You shouldn’t get any errors about missing libraries. I recommend retrieving a fresh copy from the repository if you were using JavaSVN before, I still had problems until I did that.

My problem in Debian sid may have been that I didn’t change the Eclipse command line to point to /usr/lib.

© 2013 Nilesh D Kapadia