在Linux上安装JDK

作者:聂勇 欢迎转载,请保留作者信息并说明文章来源!

预备

  • SUSE LINUX Enterprise Server 9
  • jdk-6u10-linux-i586.bin

安装

1、赋予执行权限。

1
chmod +x ./jdk-6u10-linux-i586.bin

2、执行安装。

1
./jdk-6u10-linux-i586.bin

Sun Microsystems, Inc. Binary Code License Agreement

for the JAVA SE DEVELOPMENT KIT (JDK), VERSION 6

SUN MICROSYSTEMS, INC. (“SUN”) IS WILLING TO LICENSE THE
SOFTWARE IDENTIFIED BELOW TO YOU ONLY UPON THE CONDITION
THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS BINARY
CODE LICENSE AGREEMENT AND SUPPLEMENTAL LICENSE TERMS
(COLLECTIVELY “AGREEMENT”). PLEASE READ THE AGREEMENT
CAREFULLY. BY DOWNLOADING OR INSTALLING THIS SOFTWARE, YOU
ACCEPT THE TERMS OF THE AGREEMENT. INDICATE ACCEPTANCE BY
SELECTING THE “ACCEPT” BUTTON AT THE BOTTOM OF THE
AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY ALL THE
TERMS, SELECT THE “DECLINE” BUTTON AT THE BOTTOM OF THE
AGREEMENT AND THE DOWNLOAD OR INSTALL PROCESS WILL NOT
CONTINUE.

  1. DEFINITIONS. “Software” means the identified above in
    binary form, any other machine readable materials
    (including, but not limited to, libraries, source files,
    header files, and data files), any updates or error
    corrections provided by Sun, and any user manuals,
    programming guides and other documentation provided to you
    by Sun under this Agreement. “General Purpose Desktop
    Computers and Servers” means computers, including desktop,
    laptop and tablet computers, or servers, used for general
    computing functions under end user control (such as but not
    specifically limited to email, general purpose Internet
    browsing, and office suite productivity tools).
    The use of Software in systems and solutions that provide
    dedicated functionality (other than as mentioned above) or
    designed for use in embedded or function-specific software
    applications, for example but not limited to: Software
    embedded in or bundled with industrial control systems,
    wireless mobile telephones, wireless handheld devices,
    kiosks, TV/STB, Blu-ray Disc devices, telematics and
    network control switching equipment, printers and storage
    management systems, and other related systems are excluded
    from this definition and not licensed under this
    Agreement. “Programs” means Java technology applets and
    applications intended to run on the Java Platform Standard

Do you agree to the above license terms? [yes or no]yes // 输入yes同意上述协议
Unpacking…
Checksumming…
Extracting…
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
creating: jdk1.6.0_10/
creating: jdk1.6.0_10/jre/
creating: jdk1.6.0_10/jre/bin/
inflating: jdk1.6.0_10/jre/bin/java
inflating: jdk1.6.0_10/jre/bin/keytool
inflating: jdk1.6.0_10/jre/bin/policytool
inflating: jdk1.6.0_10/jre/bin/rmiregistry
inflating: jdk1.6.0_10/jre/bin/rmid
……
省略
……
Creating jdk1.6.0_10/jre/lib/rt.jar
Creating jdk1.6.0_10/jre/lib/jsse.jar
Creating jdk1.6.0_10/jre/lib/charsets.jar
Creating jdk1.6.0_10/lib/tools.jar
Creating jdk1.6.0_10/jre/lib/ext/localedata.jar
Creating jdk1.6.0_10/jre/lib/plugin.jar
Creating jdk1.6.0_10/jre/lib/javaws.jar
Creating jdk1.6.0_10/jre/lib/deploy.jar

Java(TM) SE Development Kit 6 successfully installed.

Product Registration is FREE and includes many benefits:

  • Notification of new versions, patches, and updates
  • Special offers on Sun products, services and training
  • Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the Sun Product Registration form for
the JDK will be presented. If you do not register, none of
this information will be saved. You may also register your
JDK later by opening the register.html file (located in
the JDK installation directory) in a browser.

For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

Press Enter to continue…..

Done.

3、设置环境变量。

1
vi .profile

增加如下配置:

1
2
3
4
5
6
7
8
9
10
JDK6_HOME=$USER_HOME/jdk1.6.0_10
JAVA_HOME=$JDK6_HOME
export JAVA_HOME
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export PATH
CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export CLASSPATH

提示:上述环境变量的设置仅供参考,需根据自己的实际环境作一些调整。

验证

1
java -version

java version “1.6.0_10”
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)