[英]CentOS7: Setting default JAVA as Oracle JDK and not openJDK
I have a machine with CentOS7. 我有一台装有CentOS7的机器。 The default Java is 默认的Java是
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
I want to change this to 我想将其更改为
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
To do so, I have so far followed the steps as given below. 为此,到目前为止,我已经按照以下步骤进行操作。
Download jdk-8u212-linux-x64.tar.gz file 下载jdk-8u212-linux-x64.tar.gz文件
I could not untar the above using tar -zxvf jdk-8u212-linux64.tar.gz
to a specified directory. 我无法使用tar -zxvf jdk-8u212-linux64.tar.gz
将上述文件解压缩到指定目录。 Hence I used 7-zip and the extracted the JDK1.8.0_212 folder and copied the same to /usr/lib/jvm
因此,我使用了7-zip并解压缩了JDK1.8.0_212文件夹,并将其复制到/usr/lib/jvm
Then I made the necessary changes at /etc/profile
. 然后我在/etc/profile
进行了必要的更改。 There I set the JAVA_HOME as export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_212
and followed by export PATH=$PATH:$JAVA_HOME\\bin
在那里,我将JAVA_HOME设置为export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_212
,然后依次export PATH=$PATH:$JAVA_HOME\\bin
However, when I typed update-alternatives --config java
I could not see jdk1.8.0_212/bin/java
as path. 但是,当我键入update-alternatives --config java
我看不到jdk1.8.0_212/bin/java
作为路径。 Instead I saw only openjdk
options. 相反,我只看到了openjdk
选项。
My question is: How to set my default Java as Oracle Java as mentioned above. 我的问题是:如上所述,如何将默认Java设置为Oracle Java。 The reason I am asking is I have found that sqljdbc4-x.jar
is not compatible with openJDK. 我问的原因是我发现sqljdbc4-x.jar
与openJDK不兼容。 I have already raised a query here 我已经在这里提出了一个查询
A simple approach would be to first remove Open JDK using purge then install Oracle jdk..if u are using apt-get it would automatically set the necessary Java Paths. 一种简单的方法是首先使用清除功能删除Open JDK,然后安装Oracle jdk。如果您使用的是apt-get,它将自动设置必要的Java路径。
Here is what I meant. 这就是我的意思。
yum list java*
sudo yum -y remove java*
java -version
cd
mkdir tmp
cd tmp
curl -u uftp:uftp ftp://192.168.2.115/path/developer/jdk-8u151-linux-x64.tar.gz -o jdk-8u151-linux-x64.tar.gz
tar zxvf jdk-8u151-linux-x64.tar.gz
sudo mv jdk1.8.0_151 /usr/share/
sudo vim /etc/profile
#add
export JAVA_HOME=/usr/share/jdk1.8.0_151
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source /etc/profile
java -version
which java
cheers. 干杯。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.