0

As you can see in the code below I don't have java bin in my path but I can run java & javac in any directory. I ran java & javac command in the code bellow and also I have echoed my path where you can see It doesn't include my jdk bin in it! any help would be appreciated:)) !

Can anyone explain why?

kasrakaraji@Kasras-MacBook-Pro ~> echo $PATH
/usr/local/bin /usr/bin /bin /usr/sbin /sbin /Users/kasrakaraji/anaconda3/bin /Library/Apple/usr/bin /Library/TeX/texbin /Applications/Wireshark.app/Contents/MacOS
kasrakaraji@Kasras-MacBook-Pro ~> java -version 
java version "11.0.5" 2019-10-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)
kasrakaraji@Kasras-MacBook-Pro ~> javac -version
javac 11.0.5
kasrakaraji@Kasras-MacBook-Pro ~> cd /Library/Java/JavaVirtualMachines/jdk-11.0.5.jdk/Contents/Home
kasrakaraji@Kasras-MacBook-Pro /L/J/J/j/C/Home> ls
README.html  bin/         conf/        include/     jmods/       legal/       lib/         release
  • 1
    Don't post screenshots - post any such output as text in your question. And include the output of `which java` and `which javac`. – Erwin Bolwidt Feb 24 '21 at 11:29
  • sorry I'm fairly new – kasra karaji Feb 25 '21 at 09:51
  • Does this answer your question? [Shell - How to find directory of some command?](https://stackoverflow.com/questions/2869100/shell-how-to-find-directory-of-some-command) – Joe Mar 07 '21 at 10:46

1 Answers1

0

Of course it is in your path you just don't know where your Java is.

On my systems, Linux and Mac I have my Java binary on the same places:

  1. Linux: /usr/bin/java
  2. MacOS: /usr/bin/java

To find out this information, just type this command: whereis java

Now, about your path. If you double check it you will see the folder, /usr/bin that contains the link to you java binary.

kasrakaraji@Kasras-MacBook-Pro ~> echo $PATH /usr/local/bin /usr/bin /bin

I think you are confounding the JAVA_HOME environment variable and the PATH variable.

The JAVA_HOME var point to a Java installation as an env variable and the link /usr/bin/java point to Java binary file.

ls -l /usr/bin/java lrwxrwxrwx 1 root root 22 feb 15 18:18 /usr/bin/java -> /etc/alternatives/java

On linux, you have the update-alternatives command to change all the links for a specific installation and on MacOS it will depends of the process that you choose to install Java.

btafarelo
  • 601
  • 3
  • 12