install java 8_Install JAVA 8 on Linux Systems

本文详细介绍了如何在Linux系统上安装Oracle Java 8,包括下载安装包、配置环境变量、更新Java替代项以及在Firefox中启用Java支持等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Install Java 8 in Linux

1. Before installing Java, make sure to first verify the version of installed Java.

1 # java -version2

3 java version "1.7.0_75"

4 OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-2)5 OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)

It’s clear from the output above that the installed version of Java is OpenJDK 1.7.0_75.

2. Make a directory where you want to install Java. For global access (for all users) install it preferably in the directory /opt/java.

1# mkdir /opt/java && cd /opt/java

3. Now it’s time to download Java (JDK) 8u45 source tarball files for your system architecture by going to official Java download page.

For reference, we have provided the source tarball file-names, please select and download these below mentioned files only.

1 jdk-8u45-linux-i586.tar.gz [For 32-bit Systems]2 jdk-8u45-linux-x64.tar.gz [For 64-bit Systems]

Alternatively, you may use wget command to download files directly into the /opt/java directory as shown below.

1 --------------- For 32-bit Systems ---------------

2

3 # cd /opt/java4 # wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "h ttp://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-i586.tar.gz"

5 --------------- For 64-bit Systems --------------

6

7 # cd /opt/java8 # wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "h ttp://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz"

4. Once file has been downloaded, you may extract the tarball using tar command as shown below.

1 # tar -zxvf jdk-8u45-linux-i586.tar.gz [For 32-bit Systems]2 # tar -zxvf jdk-8u45-linux-x64.tar.gz [For 64-bit Systems]

Note: I have used 64-bit tarball throughout the tutorial. If you are using 32-bit, you may change it accordingly.

5. Next, move to the extracted directory and use command update-alternatives to tell system where java and its executables are installed.

1 # cd jdk1.8.0_45/

2 # update-alternatives --install /usr/bin/java java /opt/java/jdk1.8.0_45/bin/java 100

3 # update-alternatives --config java

c323f27e37539a8f644daed9d7cc63a3.png

Update Java Alternatives

6. Tell system to update javac alternatives as:

1 # update-alternatives --install /usr/bin/javac javac /opt/java/jdk1.8.0_45/bin/javac 100

2 # update-alternatives --config javac

46fc369073e126139a28ab22cfe023f3.png

Update Javac Alternatives

7. Similarly, update jar alternatives as:

1 # update-alternatives --install /usr/bin/jar jar /opt/java/jdk1.8.0_45/bin/jar 100

2 # update-alternatives --config jar

6c4359ac589ff31943c1dd7f07e3d717.png

Update Jar Alternatives

8. Setting up Java Environment Variables.

1 # export JAVA_HOME=/opt/java/jdk1.8.0_45/

2 # export JRE_HOME=/opt/java/jdk1.8.0._45/jre3 # export PATH=$PATH:/opt/java/jdk1.8.0_45/bin:/opt/java/jdk1.8.0_45/jre/bin

b08247d0e9363d6eb42d3c1862264dd1.png

method two:  将上面的代码添加到 /etc/profile.d/profile   文件的末尾; 然后执行该文件;

Set Java Environment Variables

9. Now You may verify the Java version again, to confirm.

1 # java -version2

3 java version "1.8.0_45"

4 Java(TM) SE Runtime Environment (build 1.8.0_45-b14)5 Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

Suggested: If you are not using OpenJDK (open source implementation of java), you may remove it as:

1 # apt-get remove openjdk-*

Enable Java Support in Firefox

10. To enable Java 8 JDK 8u45 Support in Firefox, you need to run following commands to enable Java module for Firefox.

On Debian, Ubuntu and Mint

1 --------------- For 32-bit Systems ---------------

2

3 # update-alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /opt/java/jdk1.8.0_45/jre/lib/i386/libnpjp2.so 20000

4

5 --------------- For 64-bit Systems ---------------

6

7 # update-alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /opt/java/jdk1.8.0_45/jre/lib/amd64/libnpjp2.so 20000

8 On RHEL, CentOS and Fedora

On RHEL, CentOS and Fedora

1 --------------- For 32-bit Systems ---------------

2

3 # alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /opt/java/jdk1.8.0_45/jre/lib/i386/libnpjp2.so 20000

4

5 --------------- For 64-bit Systems ---------------

6

7 # alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /opt/java/jdk1.8.0_45/jre/lib/amd64/libnpjp2.so 20000

11. Now verify the Java support by restarting Firefox and enter about:plugins on the address bar. You will get similar to below screen.

688e19fd47da86741cb207f08e844529.png

Java 8 Support in Firefox

That’s all for now. Hope this post of mine will help you in setting oracle Java, the easiest way. I would like to know your view on this. Keep connected, Stay tuned! Like and share us and help us get spread.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值