1

I installed jdk-8u91-linux-x64.rpm onto my CentOS box, got no errors.

However, when I write the command it is still displaying Java 7, not the Java 8 I installed.

$ java -version

java version "1.7.0_09-icedtea" OpenJDK Runtime Environment (rhel-2.3.4.1.el6_3-x86_64) OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)

I need to leave Java7 files, but need java to use 8.

1
  • you most probably need to update your $PATH variable. I am not sure how CentOS manages environment variables and software alternatives, but you might want to look into this topic. Maybe this helps. Commented May 18, 2016 at 10:22

3 Answers 3

1

You missing the following:

cd /opt/jdk1.8.xxx/
alternatives --install /usr/bin/java java /opt/jdk1.8.xxx/bin/java 2
alternatives --config java

alternatives --install /usr/bin/jar jar /opt/jdk1.8.xxx/bin/jar 2
alternatives --install /usr/bin/javac javac /opt/jdk1.8.xxx/bin/javac 2
alternatives --set jar /opt/jdk1.8.xxx/bin/jar
alternatives --set javac /opt/jdk1.8.xxx/bin/javac

For more information: http://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/

Sign up to request clarification or add additional context in comments.

Comments

0

Run this and it will find all instances of java installed:

update-alternatives --config java

Then select the version to default to.

/Thread

Comments

0

To see which version(s) of JDKs are installed, run the below command:

update-java-alternatives --list

Use java -version , to see which Java version you are currently using.

To use the latest OpenJDK 8, follow the following steps to install and set OpenJDK 8 the default Java version:

Enter the following command, type user password and hit Enter to continue.

sudo add-apt-repository ppa:openjdk-r/ppa

Update system package cache with the command :

sudo apt-get update

Install OpenJDK 8 by running :

sudo apt-get install openjdk-8-jdk

To make it the default version, enter :

sudo update-alternatives --config java

and select OpenJDK 8 by typing the selection number against it.

Also, set default Java Compiler by running :

sudo update-alternatives --config javac

Now run

java -version

to check if Java is updated.

Reference: http://ubuntuhandbook.org/index.php/2015/01/install-openjdk-8-ubuntu-14-04-12-04-lts/

1 Comment

There is no update-java-alternatives in CentOS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.