Search code examples
javamacosjava-home

Mac OS: java missing


I have Mac OS 10.8.4 when I type in terminal >java i got an error

Unable to locate an executable at "/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java/bin/java" (-1)

Have no idea where and when its missed...Few days ago everything was fine. How to fix that ? Is that because I installed java 1.7 ?


Solution

  • Check first: whereis java, usually it is /usr/bin/java

    Probably symbolic link for java in /usr/bin is not pointing to the right location. You can set this link manually to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java Also check other processes: javac, javadoc, javap, javaws and javah.

    Additionally you can define JAVA_HOME in your .bash_profile.

    1. cd /usr/bin
    2. ls -l | grep java - check if it is indeed pointing to that wrong location
    3. rm java - delete symbolic link
    4. ln -s /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java java
    5. try java -version