Installing JavaHL for Subclipse/Eclipse on Ubuntu
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: I am using Sun Java
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
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:
NOTE: The ~/.eclipse directory is created when Eclipse is first run.
Add the following line to ~/.eclipse/eclipserc:
Save the file and close it. Restart Eclipse and JavaHL will no longer generate error messages when accessing the SVN preferences.