Tyler Pfaff
Tyler Pfaff

Reputation: 5032

Why can't OSX find my JDK?

I have found my JDK at /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk

I have this in my .bash_profile

export JAVA_HOME=/Library/Java
export PATH=$JAVA_HOME/bin:$PATH

I have saved my changes with source .bash_profile

Now when I try to run sudo apt get install gcc

I get this error

Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/apt" (-1)

What's going on here?

Upvotes: 1

Views: 9540

Answers (2)

Pawan Yadav
Pawan Yadav

Reputation: 11

For Mac users once you download and install JDK:

  1. Go to Desktop
  2. Press Command+Shift+G
  3. In the dialogue box type /Library/Java/JavaVirtualMachines/
  4. Click Go
  5. You will find the JDK installed on your system

Upvotes: -1

l'L'l
l'L'l

Reputation: 47169

Since this is more about gcc not installing as a result of not finding the java jdk, you'll want to find the current version of java used as default:

ls -l `which java`

To locate a specific version use (1.8 for example):

/usr/libexec/java_home -v 1.8

To locate all versions installed:

/usr/libexec/java_home -V

You'll need to update your PATH to reflect the location of the jdk (normally for 1.8.0 it should be):

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0)
export PATH=$JAVA_HOME/bin:$PATH

You would add that to your ~/.bash_profile and should be back in business.

Further info: https://developer.apple.com/library/mac/qa/qa1170/_index.html

Upvotes: 7

Related Questions