English
Ask Your Question
2

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

asked 2014-06-18 15:24:42 +0000

Monjur Morshed gravatar image

updated 2014-09-28 15:48:16 +0000

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

3 answers

Sort by ยป oldest newest most voted
5

answered 2014-06-18 16:19:44 +0000

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

Comments

Thanks for your help . Job done. :)

Monjur Morshed ( 2014-06-19 04:59:37 +0000 )edit

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

emery ( 2015-12-24 21:30:25 +0000 )edit

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

christianbueno ( 2017-06-16 20:35:45 +0000 )edit
1

answered 2014-06-19 12:00:23 +0000

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
1

answered 2014-06-18 16:07:38 +0000

liquidat gravatar image

You need to adjust the alternatives configuration for Java:

alternatives --display java

and

alternatives --display java

See more information on fedoraproject.org about Java.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Use your votes!

  • Use the 30 daily voting points that you get!
  • Up-vote well framed questions that provide enough information to enable people provide answers.
  • Thank your helpers by up-voting their comments and answers. If a question you asked has been answered, accept the best answer by clicking on the checkbox on the left side of the answer.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.

Question Tools

Follow
2 followers

Stats

Asked: 2014-06-18 15:24:42 +0000

Seen: 24,494 times

Last updated: Jun 19 '14