How To Install Oracle Java (JDK) On Ubuntu 22.04 LTS, Debian Linux

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 and set up Java on your Ubuntu operating system so let's get started and let's see how we can do it so first of all open your favorite browser and search for install Java and the first link which will appear here will be from oracle.com forward slash Java so we are going to install the Oracle Java on our Ubuntu operating system so click this Oracle Java link and then when you scroll down here first of all you will see the latest version of java which is available so at the time of making this video jdk 20 and jdk 17 versions are available we are going to download the jdk 20 version so just select the latest version and then scroll down for Ubuntu we are going to download the dot Deb file which is for the Debian packages so we are going to just click on this dot Deb file so I just click on this which is going to start the download of this jdk20 Dot daeb and once this file is downloaded let's go to the downloads folder and see this file so to install this dot the EB file you can open the command prompt so just press Ctrl alt t on your Ubuntu operating system which is going to open this command prompt or you can go to the applications and then click on this terminal option which is also going to open the command prompt so we are going to navigate to our downloads folder and I'm going to do LS and here I can see this jdk20.deb file right in order to install Java using this dot the EB file you need to give this command sudo tpkg hyphen I and the name of the jdk file so just write jdk here and then press tab which is going to auto complete your file name and then press enter and then give your ubuntu's password which is used to log into your Ubuntu operating system and then press enter you can see the installation of this Java jdk has been started so just wait for this command to complete now when you execute this command you may see this kind of error and this is a very common error if you haven't installed these two libraries on your Ubuntu operating system the installation of java will complain about these dependencies right so the fix is fairly easy you just need to write this command before executing the dot the EB Command right so just write sudo apt install and then we are going to give hyphen y so that it will not ask us to provide some permission again and again right and then whatever dependencies you see here I can see two of them right now which is lib C6 hyphen I 386 and lib C6 hyphen X 32. give both the names here so just copy the name and paste it here and then give space and then once again copy the name and then paste it here okay so sudo apt install hyphen Y and then the name of both the dependencies and then press enter which is going to install these dependencies so once these dependencies will be installed the previous command will work without any problem so you can see these libraries are now installed so let's once again execute our DOT Deb file for jdk which we have downloaded right earlier it was so showing the error because we had some unmet dependencies for jdk 20. so once again let me just execute this command and hopefully this time it's going to work so now you can see uh everything has worked perfectly after we have installed these libraries and and then executed this dpkg hyphen I uh jdk.deb Command right so once that's done you can clear your terminal by writing clear command now once Java is installed on your Ubuntu operating system you need to do two settings and I'm going to uh show you how to do those two settings before you can start uh using Java command and those two uh settings or those two commands are these two commands I'm going to put all these commands in the description of this video so you can directly copy and paste these commands into your terminal so this uh dpkg hyphen I command we have already executed now we need to give this command so I'm going to copy this and paste it here and this command is sudo update alternatives hyphen hyphen install and then the path of java which is user forward slash bin for slash Java and then space Java and then this jvm file path right so just give this command it will be there in the description of this video I'm going to press enter and you can see update on alternative using this path to provide this path right now if you face any problem right for example uh you are have installed Java jdk 21 then this command is not going to work because you can see the path here is 20. so if this command fails then you just need to find out what's the exact path of your Java installation so for solving that problem you can simply write forward slash use user so basically we are typing this path right so user lib jvm and then whatever is the version of jdk in your case you just need to give that part so user live forward slash jvm and then you can see I have this jdk 20 but in in your case it can be 21 22 or some other version so go until user lab jvm and here you will see the folder name and that's the exact name you need to give here in this Command right in my case it's jdk20 in your case it can be different so you need to replace this folder name here in this Command right similarly we are going to execute the second command for Java C and I'm going to just paste this command and then press enter and this is also successful now once you have executed these two commands you can use this sudo update alternatives to configure Java for example you have different versions of Java on your operating system let's say you have installed open jdk Java version you have installed Oracle Java version you can use this update Alternatives command to config or choose your Java version right so let me show you how you can do this so you can just write sudo update update Alternatives and then hyphen hyphen config and then write Java here and then press enter and for now I have only one alternative for Java which is the Oracle Java version in your case you can see multiple version if you have installed multiple version as I mentioned you might have open jdk Java version you might have Oracle Java version using this command you can select what Java version you want to use right in my case there is only one version so I don't need to choose any version the default version is already selected let's check what version of java we have installed so I'm going to just write Java hyphen hyphen version here and then press enter and now I can see that I have Java 20.0.1 now some applications also requires Java home to be set on your operating system Java home is a environment variable you can set on your Ubuntu operating system and while developing some Java program or using some Java applications uh some applications require Java home right so let me show you how you can set the Java home environment variable also so let me clear the terminal Java is already installed so we can set the Java home environment variable for this give this command sudo and then choose your favorite editor it can be Nano it can be Vim it can be any editor right so I'm going to use G edit here which is the default GUI editor which comes with Ubuntu operating system also you can choose Nano or Vim as I mentioned then forward slash EDC forward slash environment and then press enter it's going to open this path in the text editor go at the very end and then press enter and here just write Java underscore home all in capital is equal to and then give these double quotes here and then you need to give the path to your Java jdk folder you can find your Java jdk location as I have mentioned earlier in this video uh the Java jdk is Java jdk is installed in user so just write user lab forward slash jvm and then the name of your Java directory which is jdk20 in my case it can be different in your case right so you just need to uh give this path here so just copy the path to this directory right user live jvm and then whatever jdk version you have and then paste it between these two double quotes right once you have done that just save your file Ctrl s and just close your file you can also press this save button and then close your file right once that is done what you need to do you can give this command so let me clear the terminal and then just write Source forward slash Etc power slash environment so because we have set a new environment variable in the ETC forward slash environment file we need to update uh that into our bash RC right so just um give this command and once you are done you can give the echo command to know the Java home environment variable value so give echo space dollar Java underscore home press enter and it's going to give you the path of your jdk folder so this is how you can set the Java home environment variable so this is how you can download and install and configure Java on your Ubuntu operating system I hope you've enjoyed this video and I will see you in the next video foreign
Info
Channel: ProgrammingKnowledge
Views: 99,168
Rating: undefined out of 5
Keywords: Windows 10, Microsoft Windows (Operating System), Java (Programming Language), Installation (Award-Winning Work), Java Development Kit (Software), Computer, How-to (Website Category), Java (Software), install Java JDK, How to install Java JDK, JAVA_HOME, Java JDK, Install Java, JRE, JDK, Java Runtime Environment, Java SE Development Kit, Download Java, Oracle, Javaprogramming, Javatutorialforbeginners, Javatutorial, Ubuntu 20.04 LTS, Debian, Linux
Id: vVrIDJ--GOA
Channel Id: undefined
Length: 13min 10sec (790 seconds)
Published: Mon Jun 12 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.