Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I downloaded a fuller version of java, and I wanted to update the default path to java. I tried updating the bashrc file as they did here http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/ , but that did not work. How do I fix this?

share|improve this question
Did you change 1.5.0_07 to the version you downloaded? Where did you install the new version? Was it an .rpm, a .tar, a .bin, or something else? Where and how did you download the new version? Which URL or command did you use? – Mikel May 25 '12 at 4:50
Yeah, I downloaded it, etc. and set the path variable to that location. But it looks in the previous location first. (i.e. if I run 'which java', it gives the path to the old download. Is there a way (other than by just moving the old java) to reorder the places that it looks for java? – user1253952 May 25 '12 at 5:03
up vote 0 down vote accepted

You need to add your new java path to the beginning of the PATH variable. Check the following example.

export PATH=/usr/java/jdk1.7/bin:$PATH

Then, type source /etc/profile or ~/.bashrc to reload the path settings.

share|improve this answer
oh my, that's all it was :/ thanks so much! – user1253952 May 25 '12 at 5:39

Also I needed to do this export JAVA_HOME=/usr/local/java/ Where /usr/local/java/ is a symbolic link for the current version of java that you want the server to use. Also in the /etc/profile file I set the following:

export JAVA_HOME=/usr/local/jdk1.8.0_31/
export PATH=$JAVA_HOME/bin:$PATH
share|improve this answer
Please don't post multiple answers. Edit your first one and include all relevant information. Each answer should stand alone, so please explain the entire process you followed in a single post then delete the other one. Finally, changing links in /etc/alternatives manually is not a good idea, that's what update-alternatives is for. In this case, update-java-alternatives. – terdon Feb 18 '15 at 11:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.