zoukankan      html  css  js  c++  java
  • Ubuntu jdk 8 与 6 切换 (安装与配置)

    1. Switch To Oracle JDK8

    1 Switch To Oracle JDK8 
    1.1 Switch Oracle JDK in the Unbuntu 14.04 
    
    Step1 :  Download a .tar.gz from Oracle(here i will be using jdk-8u91-linux-x64.tar.gz)    http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
    Step2 :   Extract it to directory /usr/lib/jvm
     After extract it and set the permission 
    $sudo chmod -R 777 /usr/lib/jvm/jdk1.8.0_91/
    
    Step3 : Update the new JAVA environment , run below command one by one 
    
    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_91/bin/java" 1
    
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_91/bin/javac" 1
    
    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.8.0_91/bin/javaws" 1
    
    
    Step 4: Run below command to update the JAVA environment 
    sudo update-alternatives --config java
    
    
    root@icilubuntu-HP-Compaq-6000-Pro-MT-PC:/usr/lib/jvm/oracle-jdk-6u35# sudo update-alternatives --config java
    There are 2 choices for the alternative java (providing /usr/bin/java).
    
      Selection    Path                                               Priority   Status
    ------------------------------------------------------------
    * 0            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java      1061      auto mode
      1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java      1061      manual mode
      2            /usr/lib/jvm/jdk1.8.0_91/bin/java   1         manual mode
    
    Press enter to keep the current choice[*], or type selection number: 
    
    Select the number of  new /usr/lib/jvm/jdk1.8.0_91/bin/java and press Enter . 
    
    Now confirm that java command is the new installed one 
    Type: java -version
    Should show:
    java version "1.8.0_91"
    
    Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
    
    Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
    
    
    
    
    
    
    
    Step 5:sudo gedit /etc/profile  
    
    然后在其中加入如下的内容
    1. export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_91  
    2. export JRE_HOME=/usr/lib/jvm/jdk1.8.0_91/jre  
    3. export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin  
    4. export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH  
    
    保存并退出,输入如下命令,使以上设置生效
    1. source /etc/profile  
    
    
    Step 6: Set the Eclipse default JAVA environment 
    
    Open Eclipse to menu Window-> Preferences-Installed JREs , set it to the new JDK path 
    View Code

    Switch To Oracle JDK6

     

     

    Switch To  Oracle JDK6
    
    1. Install the oracle JDK as below 
    Step1 :  Create “oracle-jdk-6u35”  under “usr/lib/jvm/”   
    Step2 :   Put the  jdk-6u35-linux-x64.bin to “/usr/lib/jvm/oracle-jdk-6u35” and install the JDK
     Type : $/usr/lib/jvm/oracle-jdk-6u35# ./jdk-6u35-linux-x64.bin 
    *  jdk-6u35-linux-x64.bin      http://192.168.18.224:8888/svn/Work_Space/Prototype/Integration_Workspace/software_env/jdk-6u35-linux-x64.bin
    2. Set /etc/alternatives which ensure all the java related programs are using the
    same one, if not, will get the peer not authenticated error as below
    
    12:32:07,877 WARN [PortalImpl:4898] com.liferay.portal.kernel.exception.SystemException: org.jets3t.service.S3ServiceException: Request Error: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated 
    
      Step1: copy /usr/lib/jvm/.java-6-openjdk.jinfo to /usr/lib/jvm/.oracle-jdk-6u35.jinfo 
              Type:  cp .java-6-openjdk.jinfo .oracle-jdk-6u35.jinfo 
    
    Step 2: Register new alternatives in update-alternatives mechanism. Type:
    cat .oracle-jdk-6u35.jinfo | grep -E '^(hl|jre|jdk)' | awk '{print "/usr/bin/" $2 " " $2 " " $3 " 30 
    "}' | xargs -t -n4 sudo update-alternatives --verbose --install 
    
    
    Step3 : Check if successful registered, type:
    update-java-alternatives -l
    Then should show:
    oracle-jdk-6u35 30 /usr/lib/jvm/oracle-jdk-6u35 
    
    
    Step4 :  Set chosen option , type:
               sudo update-java-alternatives -s oracle-jdk-6u35
    update-alternatives: error: no alternatives for mozilla-javaplugin.so <<ignore it>>
    Now confirm that java command is the new installed one 
    Type: java -version
    Should show:
    java version "1.6.0_35"
    Java(TM) SE Runtime Environment (build 1.6.0_35-b10)
    Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01, mixed mode)
    
    
    Step5 :  Copy the certificates from openjdk directory to oracle sun directory
    Type: ls -l /etc/alternatives/keytool
    Should show: /etc/alternatives/keytool -> /usr/lib/jvm/oracle-jdk-6u35/jdk1.6.0_35/jre/bin/keytool
    
    Type: sudo cp /usr/lib/jvm/java-6-openjdk/jre/lib/security/jssecacerts /usr/lib/jvm/oracle-jdk-6u35/jdk1.6.0_35/jre/lib/security
    sudo cp /usr/lib/jvm/java-6-openjdk/jre/lib/security/cacerts /usr/lib/jvm/oracle-jdk-6u35/jdk1.6.0_35/jre/lib/security
    
    Step6 : set JAVA_HOME in tomcat's startup script /etc/init.d/tomcat6
    export JAVA_HOME=/usr/lib/jvm/oracle-jdk-6u35/jdk1.6.0_35
    View Code

     

     

  • 相关阅读:
    idou老师教你学Istio 08: 调用链埋点是否真的“零修改”?
    idou老师教你学Istio 07: 如何用istio实现请求超时管理
    idou老师教你学Istio06: 如何用istio实现流量迁移
    Strusts2笔记8--文件的上传和下载
    Strusts2笔记7--国际化
    Strusts2笔记6--拦截器
    Strusts2笔记5--数据验证
    Strusts2笔记4--类型转换器
    Struts2笔记3--获取ServletAPI和OGNL与值栈
    Struts2笔记2--动态方法调用和Action接收请求方式
  • 原文地址:https://www.cnblogs.com/lshan/p/9002033.html
Copyright © 2011-2022 走看看