Oracle Linux Server release 6.3 下安装JDK

1、操作系统环境

Last login: Fri Feb 21 18:47:52 2014 from 192.168.56.1
[root@datacenter ~]# uname -a
Linux datacenter.localdomain 2.6.39-200.24.1.el6uek.x86_64 #1 SMP Sat Jun 23 02:39:07 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
[root@datacenter ~]# more /etc/issue
Oracle Linux Server release 6.3
Kernel \r on an \m

[root@datacenter ~]# 

2、上传JDK安装包

[root@datacenter ~]# ll
total 67296
-rw-------. 1 root root     1548 Feb 17 17:02 anaconda-ks.cfg
drwxr-xr-x  2 root root     4096 Feb 21 18:37 bea
-rw-r--r--. 1 root root    30877 Feb 17 17:02 install.log
-rw-r--r--. 1 root root     9389 Feb 17 17:00 install.log.syslog
-rw-r--r--  1 root root 68852176 Feb 20 22:30 jdk-6u38-ea-bin-b04-linux-amd64-31_oct_2012-rpm.bin

3、创建JDK安装目录

[root@datacenter ~]# mkdir -p /opt/jdk
[root@datacenter ~]# mv jdk-6u38-ea-bin-b04-linux-amd64-31_oct_2012-rpm.bin /opt/jdk/

4、移除以前的JDK

[root@datacenter ~]# rpm -qa | grep jdk
java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64
[root@datacenter ~]# yum remove java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64
Loaded plugins: security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package java-1.6.0-openjdk.x86_64 1:1.6.0.0-1.45.1.11.1.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================
 Package                   Arch          Version                             Repository                                                  Size
==============================================================================================================================================
Removing:
 java-1.6.0-openjdk        x86_64        1:1.6.0.0-1.45.1.11.1.el6           @anaconda-OracleLinuxServer-201206261930.x86_64/6.3         81 M

Transaction Summary
==============================================================================================================================================
Remove        1 Package(s)

Installed size: 81 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : 1:java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64                                                                        1/1 
  Verifying  : 1:java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64                                                                        1/1 

Removed:
  java-1.6.0-openjdk.x86_64 1:1.6.0.0-1.45.1.11.1.el6                                                                                         

Complete!

5、安装JDK

[root@datacenter ~]# cd /opt/jdk/
[root@datacenter jdk]# ll
total 67240
-rw-r--r-- 1 root root 68852176 Feb 20 22:30 jdk-6u38-ea-bin-b04-linux-amd64-31_oct_2012-rpm.bin
[root@datacenter jdk]# chmod +x jdk-6u38-ea-bin-b04-linux-amd64-31_oct_2012-rpm.bin 
[root@datacenter jdk]# ll
total 67240
-rwxr-xr-x 1 root root 68852176 Feb 20 22:30 jdk-6u38-ea-bin-b04-linux-amd64-31_oct_2012-rpm.bin
[root@datacenter jdk]# ./jdk-6u38-ea-bin-b04-linux-amd64-31_oct_2012-rpm.bin 
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
  inflating: jdk-6u38-ea-linux-amd64.rpm  
  inflating: sun-javadb-common-10.6.2-1.1.i386.rpm  
  inflating: sun-javadb-core-10.6.2-1.1.i386.rpm  
  inflating: sun-javadb-client-10.6.2-1.1.i386.rpm  
  inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm  
  inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm  
  inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm  
Preparing...                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        tools.jar...
        localedata.jar...
        plugin.jar...
        javaws.jar...
        deploy.jar...
Installing JavaDB
Preparing...                ########################################### [100%]
   1:sun-javadb-common      ########################################### [ 17%]
   2:sun-javadb-core        ########################################### [ 33%]
   3:sun-javadb-client      ########################################### [ 50%]
   4:sun-javadb-demo        ########################################### [ 67%]
   5:sun-javadb-docs        ########################################### [ 83%]
   6:sun-javadb-javadoc     ########################################### [100%]

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 Oracle products, services and training
* Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the JDK Product Registration form 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.

6、配置/etc/profile环境变量,(新增加红色字体部分).

[root@datacenter jdk]# vi /etc/profile
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}


if [ -x /usr/bin/id ]; then
    if [ -z "$EUID" ]; then
        # ksh workaround
        EUID=`id -u`
        UID=`id -ru`
    fi
    USER="`id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /sbin
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
    pathmunge /sbin after
fi

HOSTNAME=`/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
else
    export HISTCONTROL=ignoredups
fi

export JAVA_HOME=/usr/java/jdk1.6.0_38/
export JAVA_BIN=/usr/java/jdk1.6.0_38/bin/
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN CLASSPATH

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
"/etc/profile" 85L, 2013C written
[root@datacenter jdk]# java -version
java version "1.6.0_38-ea"
Java(TM) SE Runtime Environment (build 1.6.0_38-ea-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)

7、验证JDK安装

[root@datacenter jdk]# java
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)

where options include:
    -d32          use a 32-bit data model if available

    -d64          use a 64-bit data model if available
    -server       to select the "server" VM
                  The default VM is server.
                  
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose[:class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
[root@datacenter jdk]# javac
Usage: javac <options> <source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are used
  -classpath <path>          Specify where to find user class files and annotation processors
  -cp <path>                 Specify where to find user class files and annotation processors
  -sourcepath <path>         Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>       Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...]Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -d <directory>             Specify where to place generated class files
  -s <directory>             Specify where to place generated source files
  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files 
  -encoding <encoding>       Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified release
  -target <release>          Generate class files for specific VM version
  -version                   Version information
  -help                      Print a synopsis of standard options
  -Akey[=value]              Options to pass to annotation processors
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system

 

posted @ 2014-02-21 22:22  ArcerZhang  阅读(1101)  评论(0编辑  收藏  举报