java for ubuntu_Install Java 8 on Ubuntu

In this article, we will learn how to install Java 8 on Ubuntu OS. We will install JDK in Ubuntu. Java is a programming technology which is actually developed by Sun Microsystems. Java is free to download and use for commercial use.

Install Java 8 on Ubuntu

How to Install Java 8 on Ubuntu?

i) At first, we will download the package file from the official website.

http://www.oracle.com/technet... The download package is different for 64 bit and 32-bit versions.

ii) We will need some superuser privileges to install JDK. So we will use the following command-

sudo su

iii) The /opt directory is actually reserved for all the software and add-on packages. This software is not part of the default installation. The command for creating the directory for JDK installation is-

mkdir /opt/jdk

ee1ab15f1adeaad116ce2a038d5915ac.png

Creating a directory for JDK installation

iv) Then we will extract java into the /opt/jdk directory:

5c5225385862f4e44482a396522e2ad7.png

tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk

Extract java into the /opt/jdk directory

v) Then we use the following command. This command verifies the file extraction into the /opt/jdk directory.

ls /opt/jdk

273e0ee4ccea635efcaffd310be3accf.png

Verifies the file extraction into the /opt/jdk directory

vi) By default, we can find java executable in /opt/jdk/jdk1.8.0_05/bin/java directory. To set it as the default JVM we will use:

update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_05/bin/java 100

update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_05/bin/javac 100

3ae4561528e5523c2161aca243a0f6d0.png

1faceba918ddd71be9a164d3cda094fb.png

Set the default JVM

Set the default JVM

vii) Then verify the java has been successfully configured. Run the following command-

update-alternatives --display java

update-alternatives --display javac

a30e6d7e78df6f260733410a5fff3ac0.png

3350ce9e8a759e5bdfacd769a1ed2681.png

Verify the java has been successfully configured

Verify the java has been successfully configured

We can check installation by-

java -version

5471d24534b4ee12aca5d2570792479e.png

Check installation by java -version

viii) We can also update Java. Hence, download an updated version of Oracle’s website and extract to the /opt/jdk directory. After that, set it as the default JVM with a higher priority number:

update-alternatives --install /usr/bin/java java /opt/jdk/jdk.new.version/bin/java 110

update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk.new.version/bin/javac 110

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值