4

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:

JAVA_HOME=/usr/lib/jvm/jdk1.7.0_15
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/lib/jvm/jre1.7.0_15
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

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

PATH="/usr/lib/jvm/jre1.7.0_15/bin:/usr/lib/jvm/jdk1.7.0_15/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/games"

I have restarted my computer several times but I still get

bash: /usr/local/bin/java: No such file or directory
Seth
  • 58,122
siamii
  • 151
  • 1
  • 2
  • 6

3 Answers3

6

Try:

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

catalesia
  • 637
  • 6
  • 11
  • 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
  • is i'm in the bin and type ./java it is recognized. java: /usr/bin/java /etc/java /usr/lib/java /usr/bin/X11/java /usr/local/bin/java /usr/local/java /usr/share/java and /usr/local/bin/java – siamii Feb 21 '13 at 19:12
  • type /usr/bin/java -version first

    you can try to symlink to whatever works, e.g. ln -s /usr/bin/java $HOME/bin/java. This is assuming that ./java command worked for you. (I assume the one in /usr/bin did)

    – catalesia Feb 21 '13 at 21:55
  • So I solved this by re-installing Ubuntu and asking my company to disconnect my computer from the central network. This way I have full admin rights on it. – siamii Feb 22 '13 at 13:06
  • Firstly, I wanted to thank you, as this worked for me. But I don't understand why this worked? If this is not so easy, is there some reference I could read? – davidlowryduda Jun 18 '13 at 05:22
1

Follow these steps:

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

    vi .bash_profile
    
  • Insert the following lines:

    #! /bin/bash
    clear
    
    JAVA_HOME=/home/anuradha/installs/jdk1.7.0_02
    PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
    JRE_HOME=/home/anuradha/installs/jdk1.7.0_02
    PATH=$PATH:$HOME/bin:$JRE_HOME/bin
    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.

Anuradha
  • 11
  • 1
0

you might double check if your JDK is x84 or x64. If the version is a wrong one, ubuntu then cannot read it and it will tells you "No such file or directory"