ÕªÒª:
±¾ÎĵµÎªÔÚDebian GNU/LinuxϵͳÉÏ°²×° Java Development Kit (JDK/J2SDK) µÄ²Î¿¼Îĵµ.
ÒòΪÐí¿ÉÖ¤µÄÎÊÌâ, ÎÞ·¨ÔÚDebianÖÐÖ±½ÓÌṩSUN¹«Ë¾µÄJava ϵͳ. Òò´ËÔÚ´ËÌṩÁË°²×°JavaµÄ·½·¨¹©Äú²Î¿¼.
1. »ñÈ¡ sunµÄJDK
¿ÉÒÔÑ¡Ôñ´Ó Java¹Ù·½ÏÂÔØ: http://java.sun.com »òÆäËüÍøÕ¾ÏÂÔØ
JRE (J2RE)
Java Runtime Environment - Èç¹û²»´òËã×Ô¼º´´½¨JavaÓ¦ÓóÌÐòµÄ»°, ½ö½ö×°Ëü¾Í¿ÉÒÔÁË.
JDK (J2SDK)
Java Development Kit - JavaµÄÈí¼þ¿ª·Å¹¤¾ß. Èç¹ûÄúÐèÒª×Ô¼º´´½¨JavaÓ¦ÓóÌÐòµÄ»°, ÔòÐèҪѡÔñ JDK.
µ±Ç°µÄ×îа汾Ϊ:
JDK: jdk-1_5_0_06-linux-i586.bin
JRE: jre-1_5_0_06-linux-i586.bin
×¢Òâ: ÔÚSDKÖÐÒѾ°üº¬ÁË JRE. ÏÂÎÄÖÐÒÔJDK ΪÀý½øÐн²Êö
2. ¹¹½¨´ò°ü»·¾³
ºÜÐÒÔË, Debian ΪÎÒÃÇרÃÅÌṩÁËSDK µÄDEB°ü¹¹½¨¹¤¾ß: java-package
# apt-get install -u java-package fakeroot
×¢Òâ: °²×°Ç°¸üÐÂÈí¼þ°üÁбí
3. ´´½¨ .deb Èí¼þ°ü
ÒÔÆÕͨÓû§ÔËÐÐ:
$ fakeroot make-jpkg jdk-1_5_0_06-linux-i586.bin
Ôڴ˹ý³ÌÖÐ,¿ÉÄÜ»á³öÏÖһЩ¾¯¸æÐÅÏ¢, ×öһЩ±ØÒªµÄÑ¡Ôñ. ¼¸·ÖÖÓºó, Ó¦µ±³öÏÖÈí¼þ°ü´´½¨³É¹¦µÄÌáʾ. ÄÇô¹§Ï², ÄúÔÚµ±Ç°Ä¿Â¼Ï»ᷢÏÖÀàËÆ:
sun-j2sdk1.5_1.5.0+update06_i386.deb
µÄÈí¼þ°ü
4. °²×°
ÄúÓ¦µ±Çл»µ½rootÓû§Ö´ÐÐÒÔÏÂÃüÁî:
# dpkg -i sun-j2sdk1.5_1.5.0+update06_i386.deb
µ±È»ÄúÓ¦µ±¸ù¾ÝÇé¿öÖ¸¶¨ÕýÈ·µÄÈí¼þ°üÃû³Æ. Õâ¸öºÜÈÝÒ××öµ½, ¼ì²éһϵ±Ç°Ä¿Â¼¾Í¿ÉÒÔÁË
5.ÅäÖû·¾³
ÔÚ/etc/profile(»ò ~/.bashrc)½Å±¾ÎļþÖмÓÈëÀàËÆÈçÏÂÄÚÈÝ
PATH=$PATH:/usr/lib/j2sdk1.5-sun/bin:/usr/lib/j2sdk1.5-sun/jre/bin
JAVA_HOME=/usr/lib/j2sdk1.5-sun
JRE_HOME=/usr/lib/j2sdk1.5-sun/jre
CLASSPATH=.:/usr/lib/j2sdk1.5-sun/lib/tools.jar:/usr/lib/j2sdk1.5-sun/lib/dt.jar
export PATH
export JRE_HOME
export JAVA_HOME
export CLASSPATH
6. ²âÊÔ
ÉèÖõ±Ç°Ä¬ÈϵÄjava½âÊÍÆ÷ update-alternatives --config java
Ö´Ðкó»á³öÏÖÀàËÆÈçϵĻÃæ:
There are 4 alternatives which provide `java'.
Selection Alternative
-----------------------------------------------
1 /usr/bin/gij-wrapper-4.1
*+ 2 /usr/lib/jvm/java-gcj/jre/bin/java
3 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
Press enter to keep the default[*], or type selection number:3
ÊäÈë Óаüº¬ "sun" µÄÐеÄÇ°ÃæµÄÊý×Ö¡£ÈçÉÏÃæÏÔʾ£¬ÔòÊäÈë 3£¬È»ºó»Ø³µÈ·¶¨¡£
¼òµ¥µÄ²âÊÔ. Ö»ÐèÖ´ÐÐÒ»ÏÂÃüÁî¾Í¿ÉÒÔÁË:
$java -version
ÄúÓ¦¸Ã»á¿´µ½Ò»Ð©ÓйØjava°æ±¾µÄÐÅÏ¢ÀàËÆÈçÏÂÄÚÈÝ:
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
ÉÔ΢Âé·³Ò»µãµÄ²âÊÔ
´´½¨Ò»¸ö¼òµ¥µÄjava³ÌÐò(Hello.java)
public class Hello {
public Hello() {
}
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
È»ºó
$ javac Hello.java
¼ì²éµ±Ç°Ä¿Â¼»á³ÉÒ»¸öÃûΪ Hello.classµÄÎļþ, È»ºóÔËÐÐ
$java Hello
Hello World!
OK,²âÊԳɹ¦!
7. °²×°²å¼þ
¶ÔÓÚ´ËÖÖ·½·¨°²×°µÄJava»·¾³, ä¯ÀÀÆ÷²å¼þÎļþλÖÃÓ¦µ±Î»ÓÚ:
$JAVA_HOME/jre/plugin/arch/ns7/libjavaplugin_oji.so
ÀýÈç: /usr/lib/j2sdk1.5-sun/jre/plugin/i386/ns7/libjavaplugin_oji.so
ÒÔ firefox(>1.0)ΪÀý:
# cd /usr/lib/mozilla-firefox/plugins
# ln -s \
/usr/lib/j2sdk1.5-sun/jre/plugin/i386/ns7/libjavaplugin_oji.so
»òÕßÒÔDebianµÄ·½Ê½:
# update-alternatives --verbose --install \
/usr/lib/mozilla-firefox/plugins/libjavaplugin.so \
firefox-javaplugin.so \
$JAVA_HOME/jre/plugin/i386/ns7-gcc29/libjavaplugin_oji.so 500
È»ºó,ÖØÆðä¯ÀÀÆ÷, ä¯ÀÀ²âÊÔÍøÒ³: http://serios.net/content/applets/viewinfoawt.php
8. жÔØ
жÔØÈí¼þ°ü:
# apt-get remove --purge sun-j2sdk1.5
жÔزå¼þ, Ö±½Óɾ³ý·ûºÅÁ´½Ó:
# rm /usr/lib/mozilla-firefox/plugins/libjavaplugin_oji.so
Èç¹ûÊÇʹÓà update-alternatives ÃüÁî°²×°µÄ²å¼þ, ¿ÉÒÔÖ´ÐÐÒÔÏÂÃüÁîɾ³ý:
# update-alternatives --remove firefox-javaplugin.so \
$JAVA_HOME/jre/plugin/i386/ns7/libjavaplugin_oji.so
9. ÖÐÎÄ»¯
°²×°ÖÐÎÄ×ÖÌå:
ÔÚ $JAVA_HOME/jre/lib/fonts/ Ŀ¼Ï´´½¨ fallback Ŀ¼.
¸´ÖÆÖÐÎÄ×ÖÌå(ÀýÈç:simsun.ttf )ÖÁ´ËĿ¼.