This tutorial describes how to install and configure latest Oracle Java JDK on CentOS 7, 6.5, and 6.4 servers. Although, the steps should work on other RPM based distributions such as RHEL 7, 6.x, Scientific Linux 6.x, and Fedora too.
First of all, update your server.
yum update
Then, search for if any older JDK versions are installed in your system.
rpm -qa | grep -E '^open[jre|jdk]|j[re|dk]'
Sample output:
gobject-introspection-1.36.0-4.el7.x86_64 pygobject3-base-3.8.2-4.el7.x86_64
To check the already installed Java version, enter the following command:
java -version
If Java 1.6 or 1.7 have been installed already, you can uninstall them using the following commands.
yum remove java-1.6.0-openjdk yum remove java-1.7.0-openjdk
Download And Install Oracle Java JDK
At the time of writing this tutorial, the latest Java JDK version was JDK 8u25. First, let us download the latest Java version.
Go to the Oracle Java download page and download the required version depending upon your distribution architecture.
As I use 64bit CentOS 7 server, I have downloaded the 64bit rpm package.
Then, go to the directory where you’ve downloaded the jdk package, and run the following command to install it.
rpm -ivh jdk-8u25-linux-x64.rpm
Sample output:
Preparing... ################################# [100%] Updating / installing... 1:jdk1.8.0_25-2000:1.8.0_25-fcs ################################# [100%] Unpacking JAR files... rt.jar... jsse.jar... charsets.jar... tools.jar... localedata.jar... jfxrt.jar...
Check Java version
Now, check for the installed JDK version in your system using command:
java -version
Sample output:
java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
As you see above, latest java 1.8 has been installed.
Setup Global Environment Variables
We can easily set the environment variables using the export command as shown below.
export JAVA_HOME=/usr/java/jdk1.8.0_25/ export PATH=$PATH:$JAVA_HOME
Now, let us check for the environment variables using commands:
echo $JAVA_HOME
Sample output:
/usr/java/jdk1.8.0_25/
Or
echo $PATH
Sample output:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.8.0_25/
However, the above method is not recommended. Because, the path will be disappeared when the system reboots. To make it permanent, you have to add the paths in the system wide profile.
To do that, create a file called java.sh under /etc/profile.d/ directory.
vi /etc/profile.d/java.sh
Add the following lines:
#!/bin/bash JAVA_HOME=/usr/java/jdk1.8.0_25/ PATH=$JAVA_HOME/bin:$PATH export PATH JAVA_HOME export CLASSPATH=.
Save and close the file. Make it executable using command:
chmod +x /etc/profile.d/java.sh
Then, set the environment variables permanently by running the following command:
source /etc/profile.d/java.sh
That’s it.
What if I didn’t remove the old JDK versions from my system?
As I mentioned before, make sure you have removed all old JDK versions from your system. If you didn’t remove the older versions from your server before installing latest JDK version, you should tell your system from where java should be executed.
By default, the JDK 1.8.x will be installed in /usr/java/jdk1.8.0_25/ location. In order to tell our system, from where java should be executed, we need to run the following commands one by one.
alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_25/jre/bin/java 20000 alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_25/bin/jar 20000 alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_25/bin/javac 20000 alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.8.0_25/jre/bin/javaws 20000 alternatives --set java /usr/java/jdk1.8.0_25/jre/bin/java alternatives --set jar /usr/java/jdk1.8.0_25/bin/jar alternatives --set javac /usr/java/jdk1.8.0_25/bin/javac alternatives --set javaws /usr/java/jdk1.8.0_25/jre/bin/javaws
All done. Let us check the alternatives.
ls -lA /etc/alternatives/
Sample output:
lrwxrwxrwx. 1 root root 29 Dec 2 16:24 jar -> /usr/java/jdk1.8.0_25/bin/jar lrwxrwxrwx. 1 root root 34 Dec 2 16:24 java -> /usr/java/jdk1.8.0_25/jre/bin/java lrwxrwxrwx. 1 root root 31 Dec 2 16:24 javac -> /usr/java/jdk1.8.0_25/bin/javac lrwxrwxrwx. 1 root root 36 Dec 2 16:24 javaws -> /usr/java/jdk1.8.0_25/jre/bin/javaws [...]
That’s it. Now check for the java version using command:
java -version
Sample output:
java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Cheers!
相关推荐
在 CentOS7 中,默认情况下已经安装了 OpenJDK,为了避免与 JDK1.8 冲突,需要卸载系统自带的 OpenJDK。首先,需要查看系统是否自带 JDK,键入命令 `java -version`,如果结果显示有 OpenJDK 的版本信息,说明系统...
centos7 安装jdk tomcat oracle
Exception in thread "main" java.lang.UnsatisfiedLinkError: /app/oracle/product/11.2.0/jdk/jre/lib/amd64/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory ...
本TXT文件为第一章:Linux 下安装 JDK 测试环境:系统 CentOS 5.2 第一步:查看Linux自带的JDK是否已安装并卸载…… 第二步:安装JDK步骤…… 第三步:配置环境变量 三步完成安装 其他安装请见...
linux centos7下安装jdk、weblogic、Oracle超详细步骤
替换oracle解压之后的database文件中的filegroup2文件 路径 :database/stage/Components/oracle.jdk/1.6.0.75.0/1/DataFiles
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html 我下载的是这个版本,因为现在企业中还是JDK8使用的比较多。 下载完毕后把这个文件丢到Centos7服务器上,如果你用的是虚拟机,当然也...
本文将指导您在阿里云CentOs服务器上安装FTP、JDK、Tomcat、Nginx、Mysql和Oracle。 一、FTP服务器安装 * 安装vsftpd:`yum -y install vsftpd` * 设置开机启动:`chkconfig vsftpd on` * 添加用户ftpusr,并设置...
Centos7下安装Oracle11gR2
安装流程:安装VNC—安装JDK—安装Oracle 11g R2—dbca建立数据库
系统安装就不做过多介绍,大家从网上寻找安装步骤进行安装,不过我推荐大家进行安装时选择桌面图形化格式进行安装,方便做一部分操作,同时在安装过程中选择英文模式,同时我自己在安装的过程中发现使用Oracle VM ...
centos7.weblogic.oracle12c(英文)服务器安装 服务器安装部署手册(修订版)2016.5.18
jdk-8u202-linux-x64.tar.gz 为Oracle提供的java8版本最后一个免费商用版 Linux环境安装JDK8 版本至8u202步骤,包含jdk-8u202-linux-x64.tar.gz压缩包 和安装步骤
在安装 JDK1.8 之后,我们需要配置 JDK 环境变量,以便系统可以正确地识别 JDK。我们可以在 `/etc/profile` 文件中添加以下配置: ``` unset i unset -f pathmunge export JAVA_HOME=/home/hadoop/jdk1.8.0_161 ...
2、下载JDK8压缩包 wget http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz 3、查看linux系统是否有安装JDK (centos有自带JDK),若是有安装的就...
服务器:腾讯云的轻量应用服务器系 统:centOS7.6数据库:Oracle 11g连接工具:Xshell、Xftp最后附:Oracle 安装包、插件包、jdk 包下载地址;包含Oracle前置插件下载、配置详细过程;Oracle详细安装过程;安装图形...
oracle jdk-8u202 for linux amd64,备份以供使用。希望0积分可以下载,不知道在哪里设置
在CentOS7中创建目录存放JDK cd /usr/local mkdir java 使用Xftp将下载的安装包 jdk-8u241-linux-x64.tar.gz 上传至创建的目录中 并使用以下命令解压文件 tar -zxvf jdk-8u231-linux-x64.tar.gz 重命名文件,方便...
安装环境为:32位 cenos6.4,32位 Oracle11g,jdk1.7; 安装教程中除了在线安装的rpm包,需要手动安装的包都可以再extra中找到; 本文中的有些内容来自于网上,对其中的错误进行了修改,写完后,亲测可行。
自己学习整理的centos6.6下安装oracle12c的步骤,安装Centos的步骤,安装jdk,tomcat的步骤,等等