zz Debian里安装java环境和eclipse
时间:2008-11-10 来源:chiang
# su root
切换到 超级用户,进入下载目录
# chmod a+x jdk-1_5_0-linux-i586.bin
# ./jdk-1_5_0-linux-i586.bin
同意协议.会得到一个jdk-1.5.0目录。
#mkdir /usr/lib/j2se
#mv jdk-1.5.0 /usr/lib/j2se/5.0
#cd /usr/lib
#ln -s /usr/lib/j2se/5.0 java
编辑/etc/mailcap文件,将其中的java web start设置移至文件顶部的,不然在update-mime,自定义的设置会被冲掉
# ----- User Section Begins ----- #
# ----- User Section Ends ----- #
改成如下:
# ----- User Section Begins ----- #
# Java Web Start
application/x-java-jnlp-file; /usr/lib/java/jre/bin/javaws %s
# ----- User Section Ends ----- #
好了,基本上已经安装好了。下面解决系统的依赖性。
#apt-get install java-common
这时在/usr/share/doc/java-common有debian java的详细文档:
debian-java-faq
debian-java-policy
#cd /usr/share/doc/java-common/dummy-packages/
里面有5 个文件:
java1-runtime-dummy.control
java2-compiler-dummy.control
java2-runtime-dummy.control
java-compiler-dummy.control
java-virtual-machine-dummy.control
首先请确定已经安装好了equivs (如果没有安装就先来个apt-get install equivs)
# equivs-build java1-runtime-dummy.control
# equivs-build java2-compiler-dummy.control
# equivs-build java2-runtime-dummy.control
# equivs-build java-compiler-dummy.control
# equivs-build java-virtual-machine-dummy.control
生成5个。deb包。
#dpkg -i *.deb
#cp /usr/lib/java/jre/plugin/desktop/sun_java.desktop /usr/share/control-center-2.0/capplets/
编辑/usr/share/control-center-2.0/capplets/sun_java.desktop
修改java路径:
[Desktop Entry]
Name=Java
Comment=Java Control Panel
Exec=/usr/lib/java/bin/ControlPanel
Icon=/usr/lib/java/jre/plugin/desktop/sun_java.png
Terminal=0
Type=Application
Categories=Application;Settings;X-Sun-Supported;X-Red-Hat-Base;
这样就可以通过菜单启动java 控制台了。
最后,为jdk的bin下的命令建立链接,为mozilla安装插件,新建一个shell文件,内容如下:
#!/bin/bash
JDK_HOME=/usr/lib/java
for i in $JDK_HOME/bin/*; do
altname=`basename $i`
echo "Processing $altname..."
echo ""
if [ -x "$i" -a -e "$JDK_HOME/man/man1/${altname}.1" ]
then
update-alternatives --verbose --install /usr/bin/$altname $altname $i 500
--slave /usr/share/man/man1/${altname}.1 ${altname}.1 $JDK_HOME/man/man1/${altname}.1
else
update-alternatives --verbose --install /usr/bin/$altname $altname $i 500
fi
done
update-alternatives --verbose --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so $JDK_HOME/jre/plugin/i386/ns7/libjavaplugin_oji.so 500
#update-alternatives --install /usr/share/gnome/vfolders/Settings/sun-java.desktop sun-java.desktop /usr/lib/java/jre/plugin/desktop/sun_java.desktop 500
#sh your_shell
测试:
#java -version
会输出:
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
#man java
就可以查java的使用方法。
最后安装eclipse
apt-get install eclipse
启动时提示出错,并且版本不对,可以这样修改:
gedit /etc/eclipse/java_home
进行修改就可以了,把其中一个修改为你的JAVA_HOME的路径,这里就把其中一个改为/usr/lib/java
/usr/lib/jvm/java-gcj
/usr/lib/kaffe/pthreads
/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.5-sun
/usr/lib/j2sdk1.4-sun
(这一步你可以仔细打开/usr/bin/eclipse查看就可以找出路径的。这外eclipse可以通过创建桌面启动器得出,从应用程序里创,从属性看。)
再运行就OK了。
相关阅读 更多 +