0

I've tried installing Java several times and although the installation is apparently successful when I run

$ java -version 

I get

-bash: java: command not found

When I run

$ sudo update-alternatives --config java

I get No alternatives for java. I tried

$ jenv add /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/

and got

/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/ is not a valid path to java installation
5
  • How did you install Java ? Feb 5, 2015 at 20:59
  • What java version did you attempt to install and what command did you use?
    – Mars
    Feb 5, 2015 at 21:00
  • I attempted to install java 7, installed it from the oracle website
    – user3089079
    Feb 5, 2015 at 21:11
  • Is this Linux or MacOS? I would not use jenv until java works. Try to use the fill path to the java binary first. If this works you can add it to PATH. Oracle Java does not register alternatives (but you could do it manually).
    – eckes
    Feb 5, 2015 at 21:23
  • it is MacOS. am unsure how to do it manually
    – user3089079
    Feb 5, 2015 at 22:08

1 Answer 1

0

You're simply missing the environment variable...

edit $HOME/.bash_profile

Add

JAVA_HOME=/System/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/

Also, modify the PATH to add the bin of Java

 PATH=$PATH:$JAVA_HOME\bin

Make sure to recall .bash_profile if you do not reload bash

. $HOME/.bash_profile

now java -version should work.

4
  • No, tried that, still does not work
    – user3089079
    Feb 5, 2015 at 21:13
  • @user3089079 what is in the folder /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/ ? Feb 5, 2015 at 21:13
  • there isn't a java folder under library
    – user3089079
    Feb 5, 2015 at 22:06
  • @user3089079 I just edited the path, pretty sure it will works now. Actually on Mac there is /Library folder and /System/Library... The second one contrains Java while we were using the first one. Feb 5, 2015 at 22:49

You must log in to answer this question.