Installing java on fedora using alternatives
This is mainly a note to myself regarding the “correct” installation of java on fedora, as I’m searching the concrete commands on each new setup of a fedora box.
The goal is to use the alternatives system as much as possible as this provides great flexibility.
These commands should be executed (after installing the jdk-
# The standard alternatives...
alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_23/jre/bin/java 20000
alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_23/bin/javac 20000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_23/bin/jar 20000
# And perhaps this is also useful
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.6.0_23/jre/lib/amd64/libnpjp2.so 20000
# This is the most important IMHO but kept secret on the web...
alternatives --install /usr/lib/jvm/java-1.6.0 java_sdk_1.6.0 /usr/java/jdk1.6.0_23 2000
echo 'export JAVA_HOME=/usr/lib/jvm/java-1.6.0' > /etc/profile.d/jdk.sh
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile.d/jdk.sh
The next time I install java on some system probably I’ll create a simple script that takes the version as an argument (and perhaps the architecture) to reduce this to a single step.
Please link / retweet this post so that I find it the next time when I’m searching for these commands :-)
Ok, I just put together the shell script while installing jdk 1.6.0 update 25. Here’s the script: https://gist.github.com/940463
Cheers,
Martin
Comment by Martin Grotzke — April 25, 2011 @ 2:48 pm