您好,登錄后才能下訂單哦!
本篇內容介紹了“Ubuntu下怎么安裝JDK 1.8”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
Ubuntu14.04 LTS下安裝JDK 1.8
先到Oracle官網的下載中心下載JDK8的tar包到本地。
創建應用程序主目錄
linuxidc@ubuntu:/usr/lib$ sudo mkdir jvm
解壓下載的tar包到應用程序主目錄下
linuxidc@ubuntu:~/Downloads$ sudo tar zxf jdk-8u65-linux-x64.tar.gz -C /usr/lib/jvm
重命名下文件夾
linuxidc@ubuntu:/usr/lib/jvm$ sudo mv jdk1.8.0_65 java
安裝vim(因為UBuntu默認情況下不安裝vim命令,需要用apt-get命令安裝)
linuxidc@ubuntu:/usr/lib/jvm/java$sudoapt-getinstallvim Readingpackagelists...Done Buildingdependencytree Readingstateinformation...Done Thefollowingextrapackageswillbeinstalled: vim-runtime Suggestedpackages: ctagsvim-docvim-scripts ThefollowingNEWpackageswillbeinstalled: vimvim-runtime 0upgraded,2newlyinstalled,0toremoveand6notupgraded. Needtoget5,844kBofarchives. Afterthisoperation,28.0MBofadditionaldiskspacewillbeused. Doyouwanttocontinue?[Y/n]y Get:1http://us.archive.ubuntu.com/ubuntu/trusty/mainvim-runtimeall2:7.4.052-1ubuntu3[4,888kB] Get:2http://us.archive.ubuntu.com/ubuntu/trusty/mainvimamd642:7.4.052-1ubuntu3[956kB] Fetched5,844kBin18min52s(5,159B/s)
配置環境變量,vim ~/.bashrc文件
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo vim ~/.bashrc
添加下面的內容到文件尾部
exportJAVA_HOME=/usr/lib/jvm/java exportJRE_HOME=${JAVA_HOME}/jre exportCLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib exportPATH=${JAVA_HOME}/bin:$PATH
如果你的Ubuntu上已經安裝了其他版本的JDK,你可以通過update-alternatives命令來設定比如命令Java的默認命令路徑。然后就是編譯下讓update-alternatives配置生效。
linuxidc@ubuntu:/usr/lib/jvm/java$sudoupdate-alternatives--install/usr/bin/javajava/usr/lib/jvm/java/bin/java300 update-alternatives:using/usr/lib/jvm/java/bin/javatoprovide/usr/bin/java(java)inautomode linuxidc@ubuntu:/usr/lib/jvm/java$sudoupdate-alternatives--install/usr/bin/javacjavac/usr/lib/jvm/java/bin/javac300 update-alternatives:using/usr/lib/jvm/java/bin/javactoprovide/usr/bin/javac(javac)inautomode linuxidc@ubuntu:/usr/lib/jvm/java$sudoupdate-alternatives--install/usr/bin/jarjar/usr/lib/jvm/java/bin/jar300 update-alternatives:using/usr/lib/jvm/java/bin/jartoprovide/usr/bin/jar(jar)inautomode linuxidc@ubuntu:/usr/lib/jvm/java$sudoupdate-alternatives--install/usr/bin/javahjavah/usr/lib/jvm/java/bin/javah300 update-alternatives:using/usr/lib/jvm/java/bin/javahtoprovide/usr/bin/javah(javah)inautomode linuxidc@ubuntu:/usr/lib/jvm/java$sudoupdate-alternatives--install/usr/bin/javapjavap/usr/lib/jvm/java/bin/javap300 update-alternatives:using/usr/lib/jvm/java/bin/javaptoprovide/usr/bin/javap(javap)inautomode linuxidc@ubuntu:/usr/lib/jvm/java$sudoupdate-alternatives--configjava Thereisonlyonealternativeinlinkgroupjava(providing/usr/bin/java):/usr/lib/jvm/java/bin/java Nothingtoconfigure.
最后檢查是否安裝成功
linuxidc@ubuntu:/usr/lib/jvm/java$ java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
linuxidc@ubuntu:/usr/lib/jvm/java$
“Ubuntu下怎么安裝JDK 1.8”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。