Ask Your Question

How to make oracle jdk and jre as default java in fedora 20 ?

asked 2014-06-18 10:24:42 -0500

Monjur Morshed gravatar image

updated 2014-09-28 10:48:16 -0500

mether gravatar image

I have downloaded jdk8 and its a .rpm file. But, when I use eclipse , then I see its using OpenJdk. But, in every case, even for any java application, I want to make oracle jdk and jre as default. How can I do it ? Thanks.

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted

answered 2014-06-18 11:19:44 -0500

Floyd gravatar image

Once you install the rpm file it will install the jdk for you in /usr/java/latest/bin

Now you need to update your system to use that Java instead of OpenJDK, and you can do this by using alternative & update-alternative commands. Here is how I am doing it:

  • First we need to add the new path for java - javac - jdb - javaws - and any other java component you want by doing the alternative command. Here is the exmaple:
 Fomrat:  sudo alternatives --install [The current path] java [The new path] 1
 Example: sudo alternatives --install /usr/bin/java java /usr/java/latest/bin/java 1 
  • Now you can set the new path that we just added by using update-alternative command. Once you again you need to this for all other java component you just added the path. Here is the example:
sudo update-alternatives --config java

This command gives you the list of available paths, and you should be able to see the path that you just added in previous command, so you can pick the number next to the path.

This should do it, and you can test this by running the command:

 javac --version 

The output should be the Oracle java then you are all done.

P.S To update your java just download the new rpm and install it again. This should automatically update your previous setup.

Hope that helps.

edit flag offensive delete link more


Thanks for your help . Job done. :)

Monjur Morshed gravatar imageMonjur Morshed ( 2014-06-18 23:59:37 -0500 )edit

might need "javac -version" instead of "javac --version" in order to check version

emery gravatar imageemery ( 2015-12-24 15:30:25 -0500 )edit

on fedora25: alternatives --config java , and for java version : java -version

christianbueno gravatar imagechristianbueno ( 2017-06-16 15:35:45 -0500 )edit

answered 2014-06-18 11:07:38 -0500

liquidat gravatar image

You need to adjust the alternatives configuration for Java:

alternatives --display java


alternatives --display java

See more information on about Java.

edit flag offensive delete link more

answered 2018-01-21 18:56:41 -0500

isapir gravatar image

Run alternatives --config java and choose the number next to the version that you want to set as default. For example, in my system

alternative --config java


There are 3 programs which provide 'java'.
Selection    Command
 + 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-
   2           /usr/java/jdk1.8.0_162/jre/bin/java
*  3           /usr/java/jdk-9.0.4/bin/java

Enter to keep the current selection[+], or type selection number:

The + next to 1 indicates that that is the current configuration. The * next to 3 indicates that that is the version that alternatives thinks that should be set, probably because it has the highest version.

In my case I chose option 2 because I wanted the most current update of Java 1.8 at the time of this writing.

Do the same for javac.

edit flag offensive delete link more

answered 2014-06-19 07:00:23 -0500

tonioc gravatar image

In eclipse.ini, you may add a -vm directive with path of your JVM. In Eclipse GUI, you can control the JREs in Preferences => Java => Installed JREs.

hope this helps.

edit flag offensive delete link more

Question Tools



Asked: 2014-06-18 10:24:42 -0500

Seen: 35,340 times

Last updated: Jan 21 '18