Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Java by (3.5k points)

I want to install a specific JDK (the latest for example). For this, I went to the JDK download homepage: http://java.sun.com/javase/downloads/index.jsp. I looked for a Mac version, but I'm a bit surprised to only see downloadable versions for Linux, Windows and Solaris...

Here's the message for Mac:

"Apple Computer supplies their own version of Java. Use the Software Update feature (available on the Apple menu) to check that you have the most up-to-date version of Java for your Mac."

OK BUT... when I update Java with Mac I have a JRE and not a JDK...

I don't understand why a JDK version doesn't exist that is easily downloadable/installable (like a jar to unzip?) for Mac...

1 Answer

0 votes
by (46k points)

export JAVA_HOME=`/usr/libexec/java_home` 

This will dynamically assign to JAVA_HOME the location of the first JDK listed in the "General" tab of "Java Preferences" utility.

See Apple Technical Q&A 1170: https://developer.apple.com/library/content/qa/qa1170/_index.html

If you prefer parentheses to backticks for command substitution, this also works:

export JAVA_HOME=$(/usr/libexec/java_home)

Related questions

0 votes
1 answer
asked Oct 10, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer
asked Jul 10, 2019 in Java by Krishna (2.6k points)
0 votes
1 answer

Browse Categories

...