简体   繁体   中英

Why my mac is not displaying java version?

Our help desk already installed Java 1.8_151 on our macbook pro Mohave. When I type 'which java' I get the reply as /usr/bin/java

So, I added these two lines in my.bash_profile file in my home folder /Users/pnutalap

export JAVA_HOME=/usr/bin/java
export PATH=$JAVA_HOME/bin:$PATH

When I checked immediately 'java -version' I got back the java version correctly. But today, I am getting totally different resonse like...

N201960-MAC:~ pnutalap$ java -v Unable to locate an executable at "/usr/bin/java/bin/java" (-1)

Why there is additional /java at the end? What has gone wrong? And how to correct it to show java version properly?

When I tried to move to /usr/bin/java, I got the reply

N201960-MAC:~ pnutalap$ cd /usr/bin/java -bash: cd: /usr/bin/java: Not a directory

Looks like within /usr/bin/ folder, the 'java' is not a directory, but a symbolic link. Now it makes sense why it is trying to say Unable to locate an executable at "/usr/bin/java/bin/java" simply going by the PATH variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM