Linux系统配置JDK

  • 检查系统自带的JDK
  • [root@localhost jdk]# rpm -qa|grep jdk
    jdk-1.7.0_67-fcs.x86_64

     

  • 卸载自带的JDK
  • [root@localhost jdk]# rpm -e --nodeps jdk-1.7.0_67-fcs.x86_64
  •  安装新的JDK
  • [root@localhost jdk]# pwd
    /home/listen/jdk
    [root@localhost jdk]# ll
    total 123884
    -rw-rw-r--. 1 listen listen 126857158 Apr 26 19:53 jdk-7u67-linux-x64.rpm
    [root@localhost jdk]# rpm -ivh jdk-7u67-linux-x64.rpm 
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:jdk-2000:1.7.0_67-fcs            ################################# [100%]
    Unpacking JAR files...
    	rt.jar...
    	jsse.jar...
    	charsets.jar...
    	tools.jar...
    	localedata.jar...
    	jfxrt.jar...
    [root@localhost jdk]# 

     

  •  找到JDK的解压目录
  • [root@localhost jdk1.7.0_67]# pwd
    /usr/java/jdk1.7.0_67
    [root@localhost jdk1.7.0_67]# ll
    total 19756
    drwxr-xr-x. 2 root root     4096 May 11 02:31 bin
    -rw-r--r--. 1 root root     3339 Jul 25  2014 COPYRIGHT
    drwxr-xr-x. 4 root root     4096 May 11 02:31 db
    drwxr-xr-x. 3 root root     4096 May 11 02:31 include
    drwxr-xr-x. 5 root root     4096 May 11 02:31 jre
    drwxr-xr-x. 5 root root     4096 May 11 02:31 lib
    -rw-r--r--. 1 root root       40 Jul 25  2014 LICENSE
    drwxr-xr-x. 4 root root       44 May 11 02:31 man
    -rw-r--r--. 1 root root      114 Jul 25  2014 README.html
    -rw-r--r--. 1 root root      499 Jul 25  2014 release
    -rw-r--r--. 1 root root 19902868 Jul 25  2014 src.zip
    -rw-r--r--. 1 root root   110114 Jul 24  2014 THIRDPARTYLICENSEREADME-JAVAFX.txt
    -rw-r--r--. 1 root root   173559 Jul 25  2014 THIRDPARTYLICENSEREADME.txt
    [root@localhost jdk1.7.0_67]# 

     

  • 配置JDK
  • [root@localhost jdk]# vi /etc/profile
    #在文件末尾追加以下内容,保存
    export JAVA_HOME=/usr/java/jdk1.7.0_67
    export JRE_HOME=${JAVA_HOME}/jre
    export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
    export PATH=${JAVA_HOME}/bin:$PATH
    
    #保存完毕,后重新加载jdk信息,使配置生效
    [root@localhost jdk]# source /etc/profile
  • 测试JDK
  • [root@localhost 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
      -Werror                    Terminate compilation if warnings occur
      @<filename>                Read options and filenames from file
    
    [root@localhost jdk]# 

over! 

你可能感兴趣的:(jdk,linux)