将Fedora Core的gcj替换为sun的java的脚本
现在gcj还不支持Java 1.5,所以有很多程序执行不了。可惜Fedora Core使用的恰好是这个开源实现,而相比而言,我更喜欢Sun的Java实现,因此,无奈,每次装Fedora Core都需要去替换默认的gcj为Sun的JDK。虽然就这么几步,但是每次还老是需要google。干脆写个脚本记在blog好了。
1、换到root权限
su -
2、http://java.sun.com/j2se/1.5.0/download.jsp 下载所需要的bin,安装上。
3、然后执行下面的脚本:
--------------------CUT BEGIN-----------------------
#!/bin/bash
# Copyright (c) 2006 Dancefire (dancefire#gmail)
#
# 2 Steps to swap to Sun JDK
#
# 1. Download and install Sun Java JDK.
# 2. run this script
# 1) Tell the script the JDK directory
# 2) Help the script choose the Sun's java
# All done
echo "Configure Enviroment..."
read -p "Please tell me the JDK Directory, such as /usr/java/jdk1.5.0_07: " JDKDIR
JAVASH=/etc/profile.d/java.sh
echo "Linking to Mozilla plugins..."
ln -s $JDKDIR/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/libjavaplugin_oji.so
echo "Swap to Sun JDK ..."
if [ ! -f $JAVASH ]; then
# generate java profile
echo "export J2RE_HOME=$JDKDIR/jre" > $JAVASH
echo "export PATH=\$J2RE_HOME/bin:\$PATH" >> $JAVASH
fi
source $JAVASH
/usr/sbin/alternatives --install /usr/bin/java java $JDKDIR/bin/java 2
echo "Please choose '$JDKDIR/bin/java'"
/usr/sbin/alternatives --config java
/usr/sbin/alternatives --display java
echo "Successfully"
--------------------CUT END-----------------------
如果想恢复,只需要在root下执行:
/usr/sbin/alternatives --config java
选择回原来的gcj就可以了。
Reference:
Fedora Core 5 Linux Installation Notes
http://stanton-finley.net/fedora_core_5_installation_notes.html [English]
http://linuxertony.googlepages.com/fedora_core_5_installation_notes.html [中文版]