Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

So java -version give path not found. I have tried the following: Edit:

  • ~/.bashrc
  • ~/.profile
  • /etc/environment

bash.bashrc files and add to them the following:

export JAVA_HOME
export JRE_HOME
export PATH

In addition, I also manually added the java bin directory to PATH.


I have restarted my computer several times but I still get

bash: /usr/local/bin/java: No such file or directory
share|improve this question

2 Answers 2


sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.7.0_15/bin/java -1
sudo update-alternatives --config java

See if that works.

Read more about it at man update-alternatives

share|improve this answer
I've tried that already. Not working. Is it bad that I don't have admin rights under /usr/local even with sudo? I'm on a corporate network – siamii Feb 21 '13 at 18:26
If you don't have the rights, you should install to a path you do have rights to execute and add that path to your $HOME/.profile For example if you create /bin folder in your $HOME, by default in Ubuntu it is added to you PATH. But perhaps somebody better informed will help you here, sorry mate ;) I wouldn't know what are your privileges and [corporate] network setup. What are you trying to do anyway? – catalesia Feb 21 '13 at 18:28
btw. you should try and start with /usr/bin, not /usr/local/bin – catalesia Feb 21 '13 at 18:39
I have an installation under usr/lib/jvm All paths point to that, but the system is still trying to find it under usr/local/java All I'm trying to do is run java – siamii Feb 21 '13 at 18:53
what happens if you do: cd /usr/lib/jvm/jre1.7.0_15/bin ./java also, what output do you get on: whereis java which java – catalesia Feb 21 '13 at 18:59

Follow these steps:

  • Create a new file called .bash_profile in your home directory:

    vi .bash_profile
  • Insert the following lines:

    #! /bin/bash
    export JAVA_HOME
    export JRE_HOME
    export PATH
  • Source the .bash_profile.

  • Check the java version by running java -version.

Note: for the Ubuntu 12.04 64-bit version you need the JDK 64-bit environment.

share|improve this answer
Which directory should this be created in?? – Igor G. Mar 29 at 15:46
@IgorG. The .bash_profile file should be created in your home directory: see Where is .bash_profile for more details. – Freek de Bruijn Oct 27 at 20:20

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.