Installing JavaHL for Subclipse/Eclipse on Ubuntu 7.10

While installing the subversion plugin Subclipse in the Eclipse IDE I came across a problem. Subclipse uses "JavaHL (JNI)" to interface with subversion by default. This default setting generates an error when accessing the "Window->Preferences->Team->SVN" preferences:

Failed to load JavaHL Library.
These are the errors that were encountered:
no libsvnjavahl-1 in java.library.path
no svnjavahl-1 in java.library.path
no svnjavahl in java.library.path
java.library.path = /usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/i386/client::/
usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/i386::/usr/lib/firefox:/usr/lib/
firefox/:/usr/java/packages/lib/i386:/lib:/usr/lib

NOTE: as per the error message I am using Sun Java on my system.

This error does not seem to affect the basic subversion functionality (eg, checkout, commit, merge, etc.) and only appears when accessing the SVN preferences. However I have a custom subversion config I like to use in PHP development and I need to be able to access the SVN preferences.

The simplest way to bypass this issue is to select the "SVNKit (Pure Java)" in the "SVN interface" section of the SVN preferences. However if you require and/or desire the JavaHL subversion interface read on for a fix.

Install libsvn-java

The Debian/Ubuntu package libsvn-java has the libsvnjavahl-1.so file that is required by JavaHL subversion interface. Install libsvn-java by typing the following into a command line:

sudo  apt-get install libsvn-java

Restart Eclipse.

After installation is complete the required file (libsvnjavahl-1.so) is installed into the /usr/lib/jni directory. Default installations of Eclipse will pick this directory up automatically. Non-standard installation, such as ones installed by hand, will not find the required file.

Non-standard Installations

I need to tell Eclipse where to find libsvnjavahl-1.so for non-standard installations. The error message indicates the required file cannot be found in the paths defined by java.library.path. We can either place the file (via symlink) into one of the specified paths OR set the java.library.path to point to the /usr/lib/jni directory. Using a symlink is viable however future upgrades of java may cause the installation to break. As illustrated below I have chosen to overwrite the java.library.path variable.

Set java.library.path via eclipserc

This solution affects the Eclipse installation on a per-user basis. Changes made here will not effect anyone else using Eclipse. To over-ride the java.library.path variable we will need to create a file called eclipserc in the .eclipse directory:

gedit ~/.eclipse/eclipserc

NOTE: The ~/.eclipse directory is created when Eclipse is first run.

Add the following line to ~/.eclipse/eclipserc:

VMARGS="-Djava.library.path=/usr/lib/jni"

Save the file and close it. Restart Eclipse and JavaHL will no longer generate error messages when accessing the SVN preferences.

Leads and Resources

http://subclipse.tigris.org/faq.html#get-javahl
http://svn.collab.net/repos/svn/trunk/subversion/bindings/javahl/README
http://packages.ubuntu.com/cgi-bin/search_contents.pl?searchmode=filelis...
http://ubuntuforums.org/archive/index.php/t-190384.html
http://www.nileshk.com/node/59

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h1> <h2> <h3> <h4> <h5> <h6> <pre> <hr>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
5 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.