Install jdk8 on Ubuntu 14.04

JDK is an important tool which consists the base of Java programming as well as supports many other programming IDEs.
This article introduces the installation method of Oracle jdk 8 on Ubuntu 14.04.

Download Linux jdk 8u60

You could either download the .tar.gz package from oracle website or use command terminal.

$ wget -c http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.tar.gz

The default download path (not from command terminal) is /Home/Downloads/.

Decompress the jdk file

Create a folder under /usr/lib.

$ mkdir -p /usr/lib/jvm

If your access is denied, that means you need to use root to realize that.
You can either:

$ sudo -i

or change directly the right your username group as root:

$ sudo gedit /etc/passwd

In the file poped up, find the line with your username, for instance, your username is “blabla” then find ” blabla:x:1000:1000:crystal:/home/linuxidc:/bin/bash”.
Modify the two 1000 to two 0: “blabla:x:0:0:crystal:/home/linuxidc:/bin/bash”. This method is not recommanded since it’s a bit dangerous.

You will find that the start symbol of command line is “#” instead of “$” and you can create the folder again.

Then type the following code (suppose we don’t modify the user right and the downloaded file is saved under /Home/):

$ sudo mv jdk-8u60-linux-x64.tar.gz /usr/lib/jvm
$ cd /usr/lib/jvm
$ sudo tar xzvf jdk-8u60-linux-x64.tar.gz
$ sudo ln -s jdk1.8.0_60 java-8

Set environment variable

$ vi ~/.bashrc

If you feel sufferred using vi, try to install vim then use it.

$ sudo apt-get remove vim-common
$ sudo apt-get install vim
$ vim ~/.bashrc

Press i to switch to insert mode and enter the info below:

export JAVA_HOME=/usr/lib/jvm/java-8
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

Press Esc to quit insert mode. Enter :w! to save the changes and enter :q to quit vi.
Source the file and activate the changes.

$ source ~/.bashrc

Set default jdk version

The default version of jdk in some OS is OpenJDK. So you need to specify the default to be jdk from Oracle.

$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-8/bin/java 300
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-8/bin/javac 300
$ sudo update-alternatives --config java

In Ubuntu 14.04 OpenJDK is not preloaded, so I don’t need to do this step.

Test and configure

Check if the installation is successful.

$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

The info returned proves that we’ve successfully installed Oracle jdk 8u60.


Reference:

  1. Ubuntu 14.04 安装 JDK 8,ubuntu14.04
  2. vi in Linux
  3. 解决ubuntu中vi不能正常使用方向键与退格键的问题
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值