How to Install Java JDK on Mac OS and set JAVA HOME variable

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome I'm ragav and today we are going to learn how to install Java jdk on Mac operating system and we will also learn how to set the Java home environment variable this is going to be very easy and very interesting and do not worry if you are doing it for the first time or you are a complete beginner we will start from scratch and we will go up step by step so step number one is we will first check if Java is already installed and for that we will run the command Java space hyphen version so open Terminal I'm pressing command plus space on my keyboard it will bring up the spotlight search and I will start typing terminal and hit enter so I have got the terminal window and I will change the format so I will go to this terminal and I will say I will go to settings and I will go to profiles and I will choose this and make it default so here I'm using this font if you want you can change the font from here so I will close and I can now open thumbnail again and now you can see it opens in a different format so for checking Java I will say Java space hyphen version and I can also say Java C to check the Java compiler and if you get some version of java that means Java is already installed and set on your system but if you get something like this that the operation couldn't be completed that means Java is not installed or not set up on the system so then Second Step will be to download and install Java now there are different ways that you can use to set up Java on Mac operating system you can directly download it and then set it up or you can use something like home brew now sometime ago I created a video uh on how to install Java without log to Oracle so this is the video where uh I have shown how you can install Java without log to Oracle I will keep a link of this video in the description of this video also if you want you can go on my website that is Automation stepbystep decom and here if you scroll down to the programming section I have Java here here also so I have an old video on how to install and set up Java on Windows and Mac operating system so here for now we will use the direct way on Mac operating system that is using home brew so you can first check if home bre is already installed on your system you can say Brew hyphen version or hyphen V should work or you can also say Brew hyen hyphen version or Brew help so in my case it is not already installed that this is why I'm getting all these uh command not found I will clear the terminal and now I will use this string and I will run this on Terminal and this will install home bre you can also directly go to the home brew website which is pro. sh and you can directly copy this link from here this string from here and go to your terminal paste it and hit enter this can take some time based on the network and it will install home view on the Mac operating system so let's see it is still in process okay I'm getting this failed to connect to this link Port 443 after 7554 milliseconds could it connect to the server so uh this usually comes uh due to our Network so you can try to change your network or maybe the DNS if you're on VPN you can try to disable VPN and try uh let me check in my case I will go to my Wi-Fi settings and I will go to this is connected I'll go to DNS let me try to change my DNS and try again I will set it to 1.11.1 okay and and I'll also open a new terminal just to be sure that I'm using a new connection of terminal now and I will just copy this string again and paste it and run it and yes now it is able to access I will give my password and should be done it is downloading and installing home view now so once home view is installed we can then directly install Java using Brew I will show you that in a moment okay so this is now done let's wait for this process to get completed okay should be fine I can check now Brew hyph V uh or let me say I'll have to exit from here and I'll open a new terminal I'll quit the terminal and open a new terminal and now I will say brw space hyphen version uh or if it is blue space hyphen hyphen version uh not sure why it is not taking it let me check okay I think we missed adding uh home to the path uh let me run this again and I will get the information again so do not worry if you uh try to install it again it will check if it is already installed and you can see it is now it says installation successful uh and this is what we missed last time run these two commands in your terminal to add home view to your path so this is what I will do I have to run this so let me just copy Cy this and I can open a new tab of the terminal by pressing command T and I have run the First Command this is the second command and just copy the command from your terminal because it can be a little different for everyone uh now I will say Brew help and check and yes looks like now it is done and if I now say Brew space hyphen V I getting the version of brew as well so now we are done with step number two we have installed home brew now step number three will be we have to install jdk using home brew for this we can run Brew install open jdk this will install the latest jdk or if you want a specific version you can say Brew install open jdk at the rate whatever version you need so let's let me try with this Brew install open jdk at the rate 11 so I will say Brew I'll just copy and paste it here and let us see so you can see it will download and do the setup and installation and uh one of the good things you using home bre is it will take care of all the installation and setup and you do not have to do it manually most cases it should also set up the path for Java home but for that we will confirm and we will see how to set the Java home environment variable so it is downloading and installing and doing all the setup so this can take some time based on all the things it has to set up for the particular version of java jdk we are installing so let's just wait for this process to get completed during this uh process if you face any issues you can let me know in the comment section and I will try to find a solution for you generally it should be straightforward once you have got home brew installed and uh you use the Brew command to install any software or library on your Mac it is um generally very straightforward home brew takes care of all the setup and installation okay so it is now installing open jdk and dependencies okay so you can see this is now done and here uh here it is saying if you need to have open jdk 11 first in your path run Eco export path this command for compilers to find open jtk you may need to set export and this command so let us try this I will copy this and I can just copy and run this command and I will also copy and run this command okay now if I say Javas space hyphen version uh as of of now I'm not able to get it but if I open a new tab of the terminal or a new terminal I will say command T to open a new tab and say Java space hyph version and you can now see Java is set up and I can see the jdk version the runtime everything I can also say Java CS space hyphen version and you can see I'm also getting the Java compiler version so you can see how straightforward it is with home brew it has also set everything for us all the installation and setup is done and uh step number four is verify installation by using the command Java space hyphen version and Java c space hyphen version which we have already done so for us the process is completed now the last step that is to set Java home environment variable now if you're using home brew home brew will usually set the Java home environment variable correctly but just in case you have to manually set it you can you can do this by using these two command you can say export Java home and this is a location of jdk and you can apply this change and run this command I will keep all these notes and commands in the description of this video and you can get it from there also uh some useful tips now in all the Mac OS 10.5 or later we can use this USR libxc Java home to return the location of the default jtk so for example uh if I run this let me just open a new tab of the terminal by pressing command T and if I run this uh let me say user libxc Java home so uh let you can also go to your finder and press command shift and G key on the keyboard board that is command shift and G and check this you can start typing this as well user lib excc and then Java you can press Tab and you can see Java home is here and if I use it here with hyph v option as of now it is not able to locate all right so using all these steps we can install and set Java jdk on Mac operating system I hope this was useful if you have any questions you can let me know in the comment section I will see you soon thank you for watching and never stop learning
Info
Channel: Automation Step by Step
Views: 21,377
Rating: undefined out of 5
Keywords: how to install java on mac os, install java on apple macbook pro m2, how to set java_home environment variable on mac os, install and set java on mac os step by step
Id: mAIxIhVJ7N0
Channel Id: undefined
Length: 13min 57sec (837 seconds)
Published: Tue Oct 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.