2

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?

  • 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 04: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 05:03

2 Answers2

1

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
peterh
  • 9,731
  • 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
1

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.

terdon
  • 242,166