Get front row seat and watch the development of micro-isv. We make cool product that solves all your problems...

logo

Friends
         
Eclipse and GCJ on Debian Lenny
2008-12-05

If you run a Debian system, you have probably already had to fight to remove GJC 'Java' from your system. Unfortunately the technique that codders uses doesn't work for eclipse, because the eclipse init script helpfully bypasses the the 'alternatives' system.

Eclipse has three (or more) settings that control which JVM is used. You can run eclipse, compile your code and run your code all under different environments if you want to. First lets change the JVM used to run eclipse:

$ cat java_home 
# This file determines the search order the Eclipse Platform uses to find a
# compatible JAVA_HOME. This setting may be overridden on a per-user basis by
# altering the JAVA_HOME setting in ~/.eclipse/eclipserc.

#/usr/lib/jvm/java-6-openjdk

#/usr/lib/jvm/java-gcj

#/usr/lib/kaffe/pthreads

/usr/lib/jvm/java-6-sun
/usr/lib/jvm/java-1.5.0-sun
/usr/lib/j2se/1.5
/usr/lib/j2se/1.4
/usr/lib/j2sdk1.5-ibm
/usr/lib/j2sdk1.4-ibm
/usr/lib/j2sdk1.6-sun
/usr/lib/j2sdk1.5-sun
/usr/lib/j2sdk1.4-sun

Note the three 'Non-JVMs' have been commented out. You can check which is used by your eclipse by doing Help → about → Configuration Details. You are looking for a line like “-vm /usr/lib/jvm/java-6-sun/bin/java” any mention of gjc is wrong.

Now we can tell eclipse about the Sun JRE. Do Window → Preferences → Java → Installed JREs. Add yours, and make it the default.

Also right-click on your Java project, and do Java Build Path → Libraries. Remove the GCJ JRE and do Add Library → JRE System Library. Make sure the workspace JRE is the Sun one, and click ok.

It is also possible for the JRE used to run your app to be wrong. Go to the 'Run' dialog box, and check the JRE in there is correct too.

...And you're good to go!