Unable to locate an executable at “/usr/bin/java/bin/java” (-1)

后端 未结 8 1646
天命终不由人
天命终不由人 2020-12-13 11:53

I am having a pathetic issue with Java in my mac osx 10.7.3 . Previously I installed it and it was working fine. After some changes in the .bash_profile and .profile file in

相关标签:
8条回答
  • 2020-12-13 12:29
    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
    

    Because:

     $ find /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home -name java*
    /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java
    /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javac
    /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javadoc
    /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javafxpackager
    /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javah
    /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javap
    /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javapackager
    /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/javafx-src.zip
    /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/bin/java
    
    0 讨论(0)
  • 2020-12-13 12:31

    Most certainly, export JAVA_HOME=/usr/bin/java is the culprit. This env var should point to the JDK or JRE installation directory. Googling shows that the best option for MacOS X seems to be export JAVA_HOME=/Library/Java/Home.

    0 讨论(0)
  • 2020-12-13 12:34

    I faced the same problem. Updating bash_profile with the following lines, solved the problem for me:

    export JAVA_HOME='/usr/'
    
    export PATH=${JAVA_HOME}/bin:$PATH
    
    0 讨论(0)
  • 2020-12-13 12:40

    i have experienced the same problem, and after reading this post i have double checked the JAVA_HOME definition in .bash_profile. It is actually:

    export JAVA_HOME=$(which java)
    

    that, exactly as Anony-Mousse is explaining, is the executable. Changing it to:

    export=/Library/Java/Home
    

    fixes the problem, tho is still interesting to understand why it's valued in that way in the profile file.

    0 讨论(0)
  • 2020-12-13 12:42

    For me, the problem occurs when I've downloaded macOS Compressed Archive which underlying directory contains

    jdk-11.0.8.jdk
    - Contents
      - Home
        - bin
        - ...
      - MacOS
      - _CodeSignature
    

    So, to solve the problem, JAVA_HOME should be pointed directly to /Path-to-JDK/Contents/Home.

    0 讨论(0)
  • 2020-12-13 12:47

    For those using newer versions of java: jhat has been removed since Java 9. Source: https://www.infoq.com/news/2015/12/OpenJDK-9-removal-of-HPROF-jhat/

    That same article recommends using Java VisualVM instead.

    0 讨论(0)
提交回复
热议问题