Martin said:
Snap. I'm certain using the alternatives is a good solution to avoiding
the gcj problems, but how well will it survive a clean install in FC8? I
ask because I only use alternatives to replace Sendmail with Postfix and
don't understand its internals.
I use another approach. I don't claim my solution is the best, but it
only requires minimal work (copying one file, replacing one symlink) to
reinstate the JDK after a fresh Linux install, e.g the upcoming move
from FC7 to FC8:
- the precondition is that /home must be in a separate partition from
those that contain the the system. This means that I can reformat
the partitions that will contain Linux (/, /boot, /var, /usr) without
losing files I've created or installed under /home.
- I installed the Sun Java JDK and associated stuff (ant, JavaMail,
etc.) in /home/java. /usr/java is a symlink that points to /home/java.
- I put a file, java.sh, in /etc/profile.d which sets up the
classpath, etc. to refer to the Sun JDK. On every login this will
be found and run by the /etc/profile script. I keep a copy of java.sh
in a directory under /home
- That left the annoyance that, unlike FC6, in FC7 the gcj commands
(java, javac, etc) have been put in /usr/bin, so I made sure that
java.sh puts the java JDK before /usr/bin in the default PATH.
- After a fresh install I copy java.sh into /etc/profile.d and recreate
the /usr/java symlink. Job done: Java is back how I want it.
alternatives works by creating symlinks to what you want. You can override
all the little /usr/bin/ links with --slave options to the alternatives command.
So in my case, /usr/java/java is always a symlink to the current JDK
installation ($JAVA_HOME), or at least the one in which I'm currently interested.
# alternatives --install /usr/java/java jdk /opt/java/jdk1.6.0_03-32 1603 \
--slave /usr/java/jre jre /opt/java/jdk1.6.0_03-32/jre
Right now, "1603" is the highest number for any "jdk" alternative, so it's the
default when in "automatic" mode.
I replace all the /usr/bin symlinks thus:
# ln -s /usr/java/java/bin/java /usr/bin/java
# ln -s /usr/java/java/bin/javac /usr/bin/javac
# ln -s /usr/java/java/bin/javadoc /usr/bin/javadoc
# ln -s /usr/java/java/bin/jar /usr/bin/jar
# ln -s /usr/java/java/bin/javaws /usr/bin/javaws
# ln -s /usr/java/java/bin/jarsigner /usr/bin/jarsigner
# ln -s /usr/java/java/bin/javah /usr/bin/javah
# ln -s /usr/java/java/bin/appletviewer /usr/bin/appletviewer
# ln -s /usr/java/java/bin/rmic /usr/bin/rmic
When I want to use a different JDK, I use
alternatives --set jdk /opt/java/ibm-java2-i386-60
This puts alternatives into "manual" mode and forces the JDK to the desired one.
All the other symlinks follow perforce.
# alternatives --display jdk
jdk - status is auto.
link currently points to /opt/java/jdk1.6.0_03-32
/opt/java/jdk1.5.0_13 - priority 1513
slave jre: /opt/java/jdk1.5.0_13/jre
/opt/java/jdk1.6.0_03 - priority 1600
slave jre: /opt/java/jdk1.6.0_03/jre
/opt/java/jdk1.6.0_03-32 - priority 1603
slave jre: /opt/java/jdk1.6.0_03-32/jre
/opt/java/ibm-java2-i386-60 - priority 600
slave jre: /opt/java/ibm-java2-i386-60/jre
Current `best' version is /opt/java/jdk1.6.0_03-32.