2

I am having trouble getting java to work. I type java -version into my terminal and get java: no such file or directory. My Mac OS X version is 10.11.1. I have the newest JDK installed 1.8.0_73 x64. I am trying to compile java files and eventually create a jar file. Tutorials just say to type in java -version. Is there something I am missing in order to use the JDK? Taylors-MacBook-Pro-4:~ Taylor$ java -version -bash: java: No such file or directory

EDIT: Echoing the $PATH gives me the following.

Taylors-MacBook-Pro-4:~ Taylor$ echo $PATH

Taylors-MacBook-Pro-4:~ Taylor$ 
Taylor Courtney
  • 813
  • 1
  • 6
  • 23
  • In that case you need to set your $PATH first. Otherwise your shell doesn't know where to find binary executable files. – Hun Feb 27 '16 at 05:18
  • How to set $PATH http://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux – Hun Feb 27 '16 at 05:21

2 Answers2

2

It might be a JAVA_HOME issue. Type:

$ export JAVA_HOME=<correct path to your java virtual machine home folder>

For me it's something like:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home

roy650
  • 633
  • 1
  • 10
  • 18
1

It looks like your $PATH is not set properly if indeed java is installed. Type $ echo $PATH and see the list. Usually java is installed at /usr/bin/ or /usr/local/bin/ directory.

Hun
  • 3,707
  • 2
  • 15
  • 15