My system java's version is 1.6, for running Eclipse I need jre 1.7. I've already downloaded and unpacked the archive of java 1.7, but I cant change the default path from /usr/bin/java to my unpacked folder path

mostly i'm using cshrc so I've made these change in the .cshrc.user file

set PATH = "$PATH":/path/to/java/jre1.7.0_67/bin

after sourcing .cshrc.user file, java -version still shows 1.6, which mean that nothing is changed, how do I change the default JAVA PATH?

  • I've not been using csh for a while but I remember using setenv instead of set. – tonioc Aug 28 '14 at 12:12

$PATH is parsed from start to end until a match is found. So for example if your $PATH is:


and you execute java -jar something.jar, shell will first look for executable java in /usr/bin. It won't find it there, so it will look in /path/to/jre6. It will find executable java in that directory so it will abandon further search and use that Java executable.

You have to add Java 7's path before path to Java 6 to use it.

Modifying $PATH is not the right way to switch between Java versions, though. You should rather use update-alternatives.

  1. Run sudo update-alternatives --config java to list available Java versions and switch between them. Your newly installed version won't be available yet.

  2. Run sudo update-alternatives --install /usr/bin/java java /path/to/jre7/java 100 to register JRE7's java.

  3. Run sudo update-alternatives --config java once again and choose JRE7's Java.


You probably have java 1.6 earlier in your path.

env | grep PATH

should confirm this.


For C shell (csh), edit the startup file ~/.cshrc:

set path=(/usr/local/jdk1.7.0/bin $path)

For bash, edit the startup file ~/.bashrc:

export PATH

Note in both cases the new JDK is added before the existing path. When you edit the above files you should remove any references to JDK 1.6.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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