Taylor Courtney
Taylor Courtney

Reputation: 813

Having trouble getting java to work on Mac terminal

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$ 

Upvotes: 2

Views: 2256

Answers (2)

roy650
roy650

Reputation: 642

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

Upvotes: 2

Hun
Hun

Reputation: 3857

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.

Upvotes: 2

Related Questions