Add the following line at the end of the .bashrc
(or .profile
) file that is in your home directory :
export PATH=$PATH:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-2.b17.el7_1.x86_64/jre/bin
This is however a very fragile approach, since it will not work as expected as soon as you update your java installation. If you want to do it more properly, I suggest a couple of ways:
look in the /etc/alternatives
folder, see if there's a link named java
pointing to the current java home (could be pointing to another link). If it's there, change the export line with
export PATH=$PATH:/etc/alternatives/java
or (depending on your system), you could have a link in /usr/lib/jvm
, something like /usr/lib/jvm/java
pointing to the most recent version of the jvm you have installed. If it's there, you can use this one, so the export line is
export PATH=$PATH:/usr/lib/jvm/java
Apart from that, if you want it to be system-wide (instead of limiting the path extension to your user), you should add the line to /etc/bashrc
(or /etc/bash-bashrc
if it's there).
As a final note, this will only work in newly-created shells, not the ones you already have, unless you issue the command
. ~/.bashrc
(or the file you've modified, if it's not .bashrc
) in those shells.
Possible duplicate of How to set alias permanently using command?
– Francisco Tapia – 2015-11-17T14:46:40.630