Ubuntu Subclipse woes – use JavaHL bindings
Posted by: admin in opensource, tutorial, tags: ubuntu subclipse eclipse javahl svnkitWe use a combination of Ubuntu + Eclipse + PHPEclipse + Subclipse in the office as a stock standard developer machine setup. Developers are free to make changes, but when in doubt this is what they get.
Over the pass couple of months though, as we have added more code into the repository we noticed that the Eclipse had really been slowing down and crashing frequently, primarily due to large memory consumption. However , developers who had dropped the Subclipse plugin and resorted to the command line client (which is the way I like it
) did not seem to be having any issues.
We had until then also been using the packaged version of eclipse that was provided by Ubuntu. Seeing that there was a new version of Eclipse 3.4 and Subclipse 1.4 out we decided to see if there was a way to solve this issue and upgrade our default install.
Long story short, it turns out that the Subclipse can either be made to use SVNKit which is a pure Java implementation or JavaHL which is a wrapper for the native C library. Turns out we had been using SVNKit all this while. No prize for guessing which one is faster and handles large repositories better
.
The problem though (as identified in the FAQ entry) that since the JavaHL requires local library support you need to make sure that the version of Subclipse you are using supports the version you have installed in your machine. With Ubuntu 8.04, the packaged version is libsvn-javahl_1.4.6 , which means that you are stuck with Subclipse 1.2, as Subclipse 1.4 requires the libsvn from Subversion 1.5. Looking through Google I stumbled upon Basilisk’s blog entry that details the problem out and enumerates possible solutions. I choose the option of running Subclipse 1.2.
So a quick recipe to getting Eclipse 3.4 (directly from the download site) + Subclipse 1.2 with the JavaHL binding running on Ubuntu 8.04 is as follows:
1. In a terminal window, do the following. This line of command is used for installing java6-jre. You need to use the Sun provided java for things to work properly.
sudo apt-get install sun-java6-jre
2. Then type this to install the libsvn-javahl library that will be used by Subclipse.
sudo apt-get install libsvn-javahl
3.Type the following to set the Sun-Java as your default JVM. This will make sure that whenever an application looks for the java command it will be using the Sun provided version.
sudo update-java-alternatives -s java-6-sun
4. Then go to the eclipse site http://www.eclipse.org – got to the download section and (http://www.eclipse.org/downloads/) and download the Eclipse package relevant for your use case. For my case I downloaded Eclipse Classic from http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops/R-3.4-200806172000/eclipse-SDK-3.4-linux-gtk.tar.gz
5. Save it into your destination folder. For my case I saved it into my home dir. (And that is what the instructions will assume from this point onwards).
6. The in a terminal do the following. Please note that the path to cd into (in the example’s case it is ~) should be replaced with the path that you actually saved the download into during Step 5.
cd ~
tar -xvzf eclipse-SDK-3.4-linux-gtk.tar.gz
7. If you type ‘ls’ now there should be an additional folder called ‘eclipse’.
8. Now we need to edit the eclipse.ini file which is in the newly created eclipse folder and add a single line at the end of the file as follows “-Djava.library.path=/usr/lib/jni” I found out that this is so that the JavaHL libraries are picked up by Eclipse.
gedit ~/eclipse/eclipse.ini
Original text:
-startup
plugins/org.eclipse.equinox.launcher_1.0.100.v20080509-1800.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.0.100.v20080606
-showsplash
org.eclipse.platform
–launcher.XXMaxPermSize
256m
-vmargs
-Xms40m
-Xmx256m
After editing:
-startup
plugins/org.eclipse.equinox.launcher_1.0.100.v20080509-1800.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.0.100.v20080606
-showsplash
org.eclipse.platform
–launcher.XXMaxPermSize
256m
-vmargs
-Xms40m
-Xmx256m
-Djava.library.path=/usr/lib/jni
9. Now you can start Eclipse by clicking on the Eclipse icon with the eclipse folder.
10. Startup Eclipse.
11. Click on Help->Software Updates->Available Software from file menu in Eclipse.
12. Click on the “Add Site” button.
13. Enter a name i.e subclipse, and the URL: http://subclipse.tigris.org/update_1.2.x (Thanks Basilisk!) (Note the link to ver 1.2 not 1.4)
14. Click on “Finish”.
15. A list of features will be presented, open the list and check the one labeled “subclipse”. There will be optional packages available as well. I was only interested in the core subclipse components.
16. Click on “Next”
17. Keep clicking through till your done.
18. The install will ask you to restart your eclipse, choose yes and continue.
19. Upon Eclipse restarting go to Menu item Window>Preferences. Once the pane Pops up select the item Team > SVN. The preference should come up and there should not be any errors. If errors come up it is probably caused because for some reason your default java is still not pointing to the sun java. For more info on this you can refer to this ubuntu forum discussion.
Anyway – I hope somebody finds this useful. Feel free to add amendments and corrections in the comments.