$show=/label

How to install Java 8 on Mac? Installing Java 8 on Latest Mac OS X (HomeBrew Guide)

SHARE:

A new guide to install java 8 on Mac OS X today. Installation steps using homebrew, manual installation, and java version switching in a simple way.

1. Introduction


In this tutorial, You'll be learning how to install Java 8 or the latest versions of java in Mac OS.
If you have got the new mac book then you are existed to install java.

This is a very easy process and will show you step by step in an easy manner.

First, let us start with the Manual Installation and next go with the HomeBrew approach which is simpler managed automatically with few commands.

Before that download the latest java from Oracle or OpenJDK official websites.

Read more on Why Java is preferred?

How to install Java 8 on Mac? Installing Java 8 on Latest Mac OS X (HomeBrew Guide)


2. Manual Installation of java 8 or Higher Versions


Let us go through the manual installation of Java 14 or 8. To run the following you would need the admin access.

2.1 Download the latest JDK or needed version for you.

2.2 Copy the tar file to the location "/Library/Java/JavaVirtualMachines"
$ cd /Library/Java/JavaVirtualMachines

$ pwd
/Library/Java/JavaVirtualMachines

$ sudo cp ~/Downloads/openjdk-14_osx-x64_bin.tar.gz /Library/Java/JavaVirtualMachines

$ pwd
/Library/Java/JavaVirtualMachines

2.3 Extract the contents here.
$ sudo tar xzf openjdk-14_osx-x64_bin.tar.gz
2.4 Delete the tarfile if you no need to keep the backup.
$ sudo rm openjdk-14_osx-x64_bin.tar.gz
2.5 Find the java version installed
$ /usr/libexec/java_home -v14

/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home
2.6 Add the java home path to the ".bash_profile" file.
open the file with the VI editor. Enter into edit mode by pressing 'i' and then add the below line. Press :wq to save and come out of VI editor.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home
2.7 Source bash_priofile file
$ source ~/.bash_profile
2.8 Test the version installed on mac properly or not using "java --version".
$ java -version
openjdk version "14" 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home

3. Installing java 8 using HomeBrew

HomeBrew provides simpler way to install and manage the software and tools required on mac without any manual intervention.
If you are new then please see the article on HomeBrew installation and  Commands shown in the previous article.

3.1 Install Homebrew or update it if you have already on mac.
The update will take some time if you have done it a long time ago.

$ brew update
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
################################################################################################################################################################ 100.0%
3.2 Add open jdk to the brew

By default, all repositories are not added to the brew. So, to add the additional repos you need to use the brew tap command.

$ brew tap adoptopenjdk/openjdk
Updating Homebrew...
3.3 Find all JDK versions are on Brew
$ brew search jdk
==> Formulae
openjdk                                                                           openjdk@11
==> Casks
adoptopenjdk                     adoptopenjdk12                   adoptopenjdk13-openj9            adoptopenjdk14-openj9-jre-large  adoptopenjdk9
adoptopenjdk10                   adoptopenjdk12-jre               adoptopenjdk13-openj9-jre        adoptopenjdk14-openj9-large      jdk-mission-control
adoptopenjdk11                   adoptopenjdk12-openj9            adoptopenjdk13-openj9-jre-large  adoptopenjdk8                    oracle-jdk
adoptopenjdk11-jre               adoptopenjdk12-openj9-jre        adoptopenjdk13-openj9-large      adoptopenjdk8-jre                oracle-jdk-javadoc
adoptopenjdk11-openj9            adoptopenjdk12-openj9-jre-large  adoptopenjdk14                   adoptopenjdk8-openj9             sapmachine-jdk
adoptopenjdk11-openj9-jre        adoptopenjdk12-openj9-large      adoptopenjdk14-jre               adoptopenjdk8-openj9-jre
adoptopenjdk11-openj9-jre-large  adoptopenjdk13                   adoptopenjdk14-openj9            adoptopenjdk8-openj9-jre-large
adoptopenjdk11-openj9-large      adoptopenjdk13-jre               adoptopenjdk14-openj9-jre        adoptopenjdk8-openj9-large
Venkateshs-MacBook-Pro-2:JavaVirtualMachines venkateshn$ 
It is showing with a blue tick for version 11. That means, My machine is already having the java 11 version.

3.4 Choose the right version and run one of the following commands.

brew cask install adoptopenjdk8
brew cask install adoptopenjdk9
brew cask install adoptopenjdk10
brew cask install adoptopenjdk11
brew cask install adoptopenjdk12
brew cask install adoptopenjdk13
brew cask install adoptopenjdk14

3.5 install JDK 14 version

This will take quite some time based on your internet speed.
$ brew cask install adoptopenjdk14
Updating Homebrew...
==> Downloading https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.1%2B7/OpenJDK14U-jdk_x64_mac_hotspot_14.0.1_7.pkg
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/233878254/64ac0f80-830e-11ea-8bcd-a9f8ee45c527?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'adoptopenjdk14'.
==> Installing Cask adoptopenjdk14
==> Running installer for adoptopenjdk14; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
Password:
installer: Package name is AdoptOpenJDK
installer: Upgrading at base path /
installer: The upgrade was successful.
package-id: net.adoptopenjdk.14.jdk
version: 14.0.1+7
volume: /
location: Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk
install-time: 1593938817
🍺  adoptopenjdk14 was successfully installed!
3.6 How to see the installed Java location?
Run from terminal "/usr/libexec/java_home -V" command which shows all java versions installed on this machine already.
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (6):
    14.0.1, x86_64: "AdoptOpenJDK 14" /Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home
    12.0.1, x86_64: "Java SE 12.0.1" /Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home
    11.0.7, x86_64: "Java SE 11.0.7" /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home
    1.8.0_252, x86_64: "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
    1.8.0_251, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
    1.8.0_161, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home
3.7 Verify the java version
$ java --version
openjdk 11.0.7 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10)
OpenJDK 64-Bit Server VM (build 11.0.7+10, mixed mode)
Currently, I have set JAVA_HOME to java 11 version. Because of this, we are seeing the java 11 version even though installed the latest java 14.
That's all. The latest version is installed.

4. How to change or Switching between Java versions

In the above sections, We've already shown you how to install the different versions of java using HomeBrew and Manual installation steps.

If you have installed any version of java and there are some cases you need to change the java version based on your project needs.

Note: In the market, there is a tool jenv.be to switch between the java versions but I prefer to use Export JAVA_HOME in .bash_profile file.

4.1 First, let us see how to see the installed versions of java.

Open the terminal and hit the "/usr/libexec/java_home -V" command and this shows all versions installed with locations.
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (6):
    14.0.1, x86_64: "AdoptOpenJDK 14" /Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home
    12.0.1, x86_64: "Java SE 12.0.1" /Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home
    11.0.7, x86_64: "Java SE 11.0.7" /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home
    1.8.0_252, x86_64: "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
    1.8.0_251, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
    1.8.0_161, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home
4.2 Open the .bash_profile file

$ vim ~/.bash_profile

Add the following to the .bash_profile file
export JAVA_HOME_8=$(/usr/libexec/java_home -v1.8)
export JAVA_HOME_11=$(/usr/libexec/java_home -v11)
export JAVA_HOME_14=$(/usr/libexec/java_home -v14)

# Java 8
export JAVA_HOME=$JAVA_HOME_8

# Java 11
# export JAVA_HOME=$JAVA_HOME_11
Save the file and come out of VI editor.

4.3 Based on the above change, we are setting JAVA_HOME to java 1.8 version.

4.4 Reload the .bash_profile
$ source ~/.bash_profile
4.5 Verify the java version
$ java -version

openjdk version "1.8.0_251"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_251-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.251-b08, mixed mode)

5. Conclusion

In this article, You have seen how to install Java on Mac OS with manual and HomeBrew Installation with step by step.

As well as seen how to change the java version as you needed from the terminal with few commands.



Ref

Oracle java 8 steps

Open JDK

HomeBrew Commands

jenv.be

How to change the Java version on Mac OS

COMMENTS

BLOGGER

About Us

Author: Venkatesh - I love to learn and share the technical stuff.
Name

accumulo,1,ActiveMQ,2,Adsense,1,API,37,ArrayList,18,Arrays,24,Bean Creation,3,Bean Scopes,1,BiConsumer,1,Blogger Tips,1,Books,1,C Programming,1,Collection,8,Collections,37,Collector,1,Command Line,1,Comparator,1,Compile Errors,1,Configurations,7,Constants,1,Control Statements,8,Conversions,6,Core Java,149,Corona India,1,Create,2,CSS,1,Date,3,Date Time API,38,Dictionary,1,Difference,2,Download,1,Eclipse,3,Efficiently,1,Error,1,Errors,1,Exceptions,8,Fast,1,Files,17,Float,1,Font,1,Form,1,Freshers,1,Function,3,Functional Interface,2,Garbage Collector,1,Generics,4,Git,9,Grant,1,Grep,1,HashMap,2,HomeBrew,2,HTML,2,HttpClient,2,Immutable,1,Installation,1,Interview Questions,6,Iterate,2,Jackson API,3,Java,32,Java 10,1,Java 11,6,Java 12,5,Java 13,2,Java 14,2,Java 8,128,Java 8 Difference,2,Java 8 Stream Conversions,4,java 8 Stream Examples,12,Java 9,1,Java Conversions,14,Java Design Patterns,1,Java Files,1,Java Program,3,Java Programs,114,Java Spark,1,java.lang,4,java.util. function,1,JavaScript,1,jQuery,1,Kotlin,11,Kotlin Conversions,6,Kotlin Programs,10,Lambda,2,lang,29,Leap Year,1,live updates,1,LocalDate,1,Logging,1,Mac OS,3,Math,1,Matrix,6,Maven,1,Method References,1,Mockito,1,MongoDB,3,New Features,1,Operations,1,Optional,6,Oracle,5,Oracle 18C,1,Partition,1,Patterns,1,Programs,1,Property,1,Python,2,Quarkus,1,Read,1,Real Time,1,Recursion,2,Remove,2,Rest API,1,Schedules,1,Serialization,1,Servlet,2,Sort,1,Sorting Techniques,8,Spring,2,Spring Boot,23,Spring Email,1,Spring MVC,1,Streams,31,String,61,String Programs,28,String Revese,1,StringBuilder,1,Swing,1,System,1,Tags,1,Threads,11,Tomcat,1,Tomcat 8,1,Troubleshoot,26,Unix,3,Updates,3,util,5,While Loop,1,
ltr
item
JavaProgramTo.com: How to install Java 8 on Mac? Installing Java 8 on Latest Mac OS X (HomeBrew Guide)
How to install Java 8 on Mac? Installing Java 8 on Latest Mac OS X (HomeBrew Guide)
A new guide to install java 8 on Mac OS X today. Installation steps using homebrew, manual installation, and java version switching in a simple way.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFYSCmJJKSx54y8-H1CC4EpiUR_Zfj770PdHqNAz3a4Uk34XEajl6TeMiIXwcOqr2lUpF1zUZ8m4Qv-5bAll5c7qgmUnXu57E3AEH2OCSnIPfH1zy6XbqJ5-QWqJ8XpTW-a6qp6CXBxnY/s640/How+to+install+Java+8+on+Mac%253F+Installing+Java+8+on+Latest+Mac+OS+X+%2528HomeBrew+Guide%2529.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFYSCmJJKSx54y8-H1CC4EpiUR_Zfj770PdHqNAz3a4Uk34XEajl6TeMiIXwcOqr2lUpF1zUZ8m4Qv-5bAll5c7qgmUnXu57E3AEH2OCSnIPfH1zy6XbqJ5-QWqJ8XpTW-a6qp6CXBxnY/s72-c/How+to+install+Java+8+on+Mac%253F+Installing+Java+8+on+Latest+Mac+OS+X+%2528HomeBrew+Guide%2529.png
JavaProgramTo.com
https://www.javaprogramto.com/2020/07/mac-install-java-8.html
https://www.javaprogramto.com/
https://www.javaprogramto.com/
https://www.javaprogramto.com/2020/07/mac-install-java-8.html
true
3124782013468838591
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content