Do you need to find out location of Java in your Mac? Its simple:
- Open Terminal
- Type the command: /usr/libexec/java_home
- Hit Enter/Return button
- If Java is available, then you will see results like this
OUTPUT:
/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Need to find specific version?
- Open Terminal
- Type the command: /usr/libexec/java_home -v 1.7
- Hit Enter/Return button
- If Java is available, then you will see results like this
OUTPUT:
/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
What happens when specified version is not available?
- Open Terminal
- Type the command: /usr/libexec/java_home -v 1.8
- Hit Enter/Return button
- If Java is available, then you will see results like this:
OUTPUT:
Unable to find any JVMs matching version “1.8”.