Sunday, January 5, 2020

How to check Java and Java home on Macs

To understand which Java you have
  • Open Terminal.
  • First confirm you have JDK by typing “which java”. It should show something like /usr/bin/java.
  • Check you have the needed version of Java, by typing “java -version”. 
  • If you do not have Java JDK, install it. Please the Java Development Kit. Not the Java Runtime Environment (JRE). To get use either the adoptJDK site or the Zulu site. For the present GEOframe system, the JDK 8 is necessary (Geotools do not work with Java 9 or more). Reasons why Oracle sites are not preferable are well documented here.
To set Java Home

  • JAVA_HOME is essentially the full path of the directory that contains a sub-directory named bin which in turn contains the java.
  • For knowing where it is, at the terminal prompt issue the command: %/usr/libexec/java_home -V
  • If you installed the adoptJDK, your directory should be something — /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

Setting JAVA_HOME for use of Java from Terminal

  • Set JAVA_HOME using this command in Terminal:  export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
  • Finally issue: echo $JAVA_HOME on Terminal to confirm the path
You should now be able to run your applications from the terminal

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.