Ubuntu 14.04 LTS下安装JDK 1.8
先到Oracle官网的下载中心下载JDK8的tar包到本地。
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
创建应用程序主目录
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$ sudo apt-get install vim
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
vim-runtime
Suggested packages:
ctags vim-doc vim-scripts
The following NEW packages will be installed:
vim vim-runtime
0 upgraded, 2 newly installed, 0 to remove and 6 not upgraded.
Need to get 5,844 kB of archives.
After this operation, 28.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main vim-runtime all 2:7.4.052-1ubuntu3 [4,888 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main vim amd64 2:7.4.052-1ubuntu3 [956 kB]
Fetched 5,844 kB in 18min 52s (5,159 B/s)
配置环境变量,vim ~/.bashrc文件
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo vim ~/.bashrc
添加下面的内容到文件尾部
export JAVA_HOME=/usr/lib/jvm/java
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
如果你的Ubuntu上已经安装了其他版本的JDK,你可以通过update-alternatives命令来设定比如命令Java的默认命令路径。然后就是编译下让update-alternatives配置生效。
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo update-alternatives –install /usr/bin/java java /usr/lib/jvm/java/bin/java 300
update-alternatives: using /usr/lib/jvm/java/bin/java to provide /usr/bin/java (java) in auto mode
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo update-alternatives –install /usr/bin/javac javac /usr/lib/jvm/java/bin/javac 300
update-alternatives: using /usr/lib/jvm/java/bin/javac to provide /usr/bin/javac (javac) in auto mode
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo update-alternatives –install /usr/bin/jar jar /usr/lib/jvm/java/bin/jar 300
update-alternatives: using /usr/lib/jvm/java/bin/jar to provide /usr/bin/jar (jar) in auto mode
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo update-alternatives –install /usr/bin/javah javah /usr/lib/jvm/java/bin/javah 300
update-alternatives: using /usr/lib/jvm/java/bin/javah to provide /usr/bin/javah (javah) in auto mode
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo update-alternatives –install /usr/bin/javap javap /usr/lib/jvm/java/bin/javap 300
update-alternatives: using /usr/lib/jvm/java/bin/javap to provide /usr/bin/javap (javap) in auto mode
linuxidc@ubuntu:/usr/lib/jvm/java$ sudo update-alternatives –config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java/bin/java
Nothing to configure.
最后检查是否安装成功
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 14.04安装JDK1.8.0_25与配置环境变量 http://www.linuxidc.com/Linux/2015-01/112030.htm
CentOS 搭建JDK环境 http://www.linuxidc.com/Linux/2015-06/118879.htm
Ubuntu 14.04安装JDK1.8.0_25与配置环境变量 http://www.linuxidc.com/Linux/2015-01/112030.htm
Ubuntu 14.04 LTS安装Oracle JDK 1.8 http://www.linuxidc.com/Linux/2014-11/109216.htm
CentOS6.3安装JDK和环境配置 http://www.linuxidc.com/Linux/2012-09/70780.htm
Ubuntu 14.04 安装 JDK8 http://www.linuxidc.com/Linux/2014-09/106218.htm
Ubuntu下安装JDK图文解析 http://www.linuxidc.com/Linux/2014-09/107291.htm
更多Ubuntu相关信息见Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-09/135403.htm