How to Install Java on Mac | Install Java JDK on macOS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys in this video I'm going to show you how you can download and install Java on your Mac operating system so let's get started and let's see how we can install Java on our Mac operating system so to start with we are going to verify if any other version of Java is installed on your Mac operating system or not so to do that just click on this search icon and then search for terminal and once this terminal ICANN is visible just click on the terminal icon which is going to open the terminal on your Mac operating system here to verify if Java is installed you need to just write Java - version command and then + Enter and then you will see this kind of output which says no Java Runtime present requesting install and you will see this kind of pop-up also if Java is installed you will see the version of Java which is installed on your Mac operating system so what we are going to do is we are going to click on this button which says more info and this is going to open the official Oracle website and here you will be able to find directly the version of Java which is the latest version which is Java SE 14 at the time of making this video if you want to search for this location manually then you can search for Oracle Java JDK on your favorite browser and the first language will appear here will be this website link so I'm going to just click on this link which will redirect me to the same page which I have seen here ok so here what you need to do is you need to click on JDK download and as I said at the time of making this video the latest version is Java SE 14 so we are going to install the version 14 on our Mac operating system now here when we will scroll down you will be able to see the packages for different operating system so we want to install it on our Mac operating system so we are going to choose the Mac OS installer so just click on the link which is in front of the Mac installer which we'll be the file with the dot dmg extension so I'm going to just click on this link and then just check this checkbox and then click on the download button so this is going to start the download of this JDK file on your Mac operating system and then just choose a file and then click on OK which is going to start the download so this is around 176 megabyte file so it will take some time to download so once this dmg file is downloaded you just need to click on this dmg file which is going to open this kind of installation wizard let me just minimize the browser and the terminal also so once this window opens you will be able to see this JDK 14 point 0 point 1 dot pkg file so 14 point 0 point 1 is the version we are going to install right so just double click on this JDK package file which is going to start this installation wizard so here just click on continue here and then click on the install button and then you just need to give your Mac operating systems password so just provide the power us word of your Mac operating system click install software which is going to start the installation of Java on your Mac operating system and in few seconds you will see this message it says install succeeded which means the Java JDK is successfully installed on your Mac operating system so just close this file and then you can just click on move to tress which is going to move this file to trash because we already have installed Java on our Mac operating system now once Java is installed on your Mac operating system you can also set the Java home environment variable on your Mac operating system so what I'm going to do is I'm going to just quit this terminal and I'm going to open the terminal once again so just search for the terminal once again and I'm going to open the terminal once again and now I have all the commands which I have listed here so to know the location of your Java home you just need to give this command I'm going to provide all these commands in the description of this video also so this command is going to give you the Java home path so I'm going to just give this command and then press ENTER and you can see we are going to set this Java home path into our environment variable as Java home so once we know the Java home path we can give this next command so we just need to open this dot Bash underscore profile file with any editor of your choice so you can give this command open till they power slash dot bash underscore profile or any editor of your choice you can list out this bash profile in your home directory also so just open your terminal and just give LS - al command and you will be able to see this bash profile file here also ok so what I'm going to do is I'm going to just clear this terminal and then I'm going to open this file using my editor which is Visual Studio code so I'm going to just write code and then the path of this bash underscore profile you can as I said use open also to open this file or whim to open this file or Nano to open this file so the editor choice is yours so I'm going to open it with the code editor which is Visual Studio code in my case and here at the very bottom I'm going to export this path so to export this path you just need to just write export Java home in capital all in capital right so just at the end just right export Java home is equal to and the path which you have found using this command which is this part so I'm going to just copy this path up to home from but the terminal and then paste it after equals to sign okay so once you are done you can just save this file so I'm going to just save this file and then I'm going to move to the next command which is source till the /khroe file file is going to refresh your bash profile in the terminal so you if next time when you give this Java home command it's going to give you the value of that till they forward slash dot bash underscore profile and then press enter and now you can echo the value of your Java home variable so just write echo and then dollar Java underscore home all in capital press ENTER and it's going to give you the value of Java home also you can give the Java version command so I'm going to clear the terminal and this time I'm going to give the Java - version command and then press ENTER and it's going to give me the version of Java which is installed on my Mac operating system so as you can see we have installed Java 14 point 0.1 so it's going to give us this version you can also give Java C - version command so Java C is used to compile or build your Java programs and it's going to give you this kind of version so this also is fourteen point zero point one now let's do something interesting let's create a file Java file and we are going to compile this file using Java C and run our program using Java command so what I'm going to do is I'm going to CD to my desk top folder so to create a Java file you just need to navigate to the location where you want to create this file I want to create this file into my desktop folder so I'm going to just go to my desktop folder right now I don't have any file in my desktop folder so I'm going to create it using touch command and then I'm going to write the name of my file which is hello world file and then you need to give the extension Java to it okay so touch HelloWorld dot Java and once you do that you can see when you do LS this file name is there which means this file is created now you can open this file using any editor of your choice you can use Eclipse IDE or NetBeans or IntelliJ IDEA also for compiling your Java code I'm going to use code editor which is Visual Studio code editor for compiling and editing this file so just write code and HelloWorld dot Java file name and it's going to open your helloworld.java file into an editor it can be any editor as I said now here I'm going to just give a simple hello world code this code you can find easily on internet anywhere so I'm going to not go into the details of this program we are just interested in compiling and running this program so this is just printing HelloWorld on the terminal when it's compiled once you have this code just save this code and then go to the terminal once again and to compile your code you just need to give Java C and the name of your file which is HelloWorld dot Java in our case and must you do that you can see that this file is created in your folder ok so if you see this file that means your compilation has both worked successfully so we just need to run it using the Java command so once you see this file you can give Java and the name of your executable file which is hello world in our case you don't need to give this dot class extension after your hello world program you just need to give this name which you see here before dot class ok so Java and then HelloWorld and when you press Enter you will see hello world is printed that means our java and javac c commands are working so as i said java c is for compiling your program and java command is for running your java program this is how you can download and install java on your mac operating system i hope you've enjoyed this video and i will see you in the next video
Info
Channel: ProgrammingKnowledge
Views: 267,752
Rating: undefined out of 5
Keywords: Java (Programming Language), Installation (Award-Winning Work), Java Development Kit (Software), Computer, Maker, How-to (Website Category), Java (Software), Tutorial, Desktop, Mac, Apple Mac, OS X, Mac OS X, JAVA_HOME, JDK, install Java, install Java JDK, macOS, JDK on macOS
Id: pxi3iIy4F5A
Channel Id: undefined
Length: 11min 27sec (687 seconds)
Published: Thu Jul 02 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.