安装
1.????去http://java.sun.com/j2se/1.4.2/download.html 下载一个Linux Platform的JDK,建议下载RPM自解压格式的(RPM in self-extracting file,j2sdk-1_4_2_06-linux-i586-rpm.bin);
2.????上载到Linux服务器上,在shell下执行命令:
[root@LinuxServer rpm]# chmod 755 j2sdk-1_4_2_06-linux-i586-rpm.bin [root@LinuxServer rpm]# ./j2sdk-1_4_2_06-linux-i586-rpm.bin |
这时会有一段Sun的协议,敲几次空格键,当询问是否同意的时候,敲yes就可以了。
????????????? Sun Microsystems, Inc. ????????? Binary Code License Agreement ?????????????????? for the JAVATM 2 SOFTWARE DEVELOPMENT KIT (J2SDK), STANDARD EDITION, VERSION 1.4.2_X … Do you agree to the above license terms? [yes or no]yes Unpacking... Checksumming... 0 0 Extracting... UnZipSFX 5.40 of 28 November 1998, by Info-ZIP (Zip-Bugs@lists.wku.edu). ? inflating: j2sdk-1_4_2_06-linux-i586.rpm? Done. |
3.????程序会自动生成一个j2sdk-1_4_2_06-linux-i586.rpm文件,这是主程序包,下面来安装;
[root@LinuxServer rpm]#rpm –ivh j2sdk-1_4_2_06-linux-i586.rpm Preparing...?????????????? ########################################### [100%] ?? 1:j2sdk?????????????? ########################################### [100%] |
附加 :如果是tar.gz等格式的,直接解压,放到USR/JAVA目录,然后设置下面环境变量就可以了
4.????设置环境变量
通常都喜欢用export命令直接在shell下设置
[root@LinuxServer rpm]# export JAVA_HOME=/usr/java/j2sdk1.4.2_06 [root@LinuxServer rpm]# export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar [root@LinuxServer rpm]# export PATH=$PATH:$JAVA_HOME/bin |
[root@LinuxServer rpm]#vi .bashrc set JAVA_HOME=/usr/java/j2sdk1.4.2_06 export JAVA_HOME set PATH=$PATH:$JAVA_HOME/bin export PATH set CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export CLASSPATH |
[root@LinuxServer rpm]# echo $JAVA_HOME /usr/java/j2sdk1.4.2_06/ [root@LinuxServer rpm]# echo $CLASSPATH /usr/java/j2sdk1.4.2_06/lib/dt.jar:/usr/java/j2sdk1.4.2_06/lib/tools.jar [root@LinuxServer rpm]# echo $PATH /usr/java/j2sdk1.4.2_06/bin/:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin [root@LinuxServer rpm]# JAVA-version JAVA version "1.4.2_06" JAVA(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03) JAVA HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode) |
5.????环境设置OK,看看JDK是否能正常工作,我们来写一个测试文件test.java
[root@LinuxServer rpm]#vi test.java class test { ?????? public static void main(String[] args) ?????? { ????????????? System.out.println("Hello World!"); ?????? } } |
保存退出,下面来编译、执行;
[
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
|