0:04
hi everyone welcome back to our Channel
0:06
today we will show you how to install
0:10
24.4 we will cover both open jdk and
0:14
Oracle jdk so that you can choose the
0:16
best one for your needs before we start
0:19
let's quickly understand the difference
0:21
between these two open jdk stands for
0:24
open Java development kit this is free
0:26
and open source version of java it is
0:28
widely used and Main by Java Community
0:32
it is a default choice for most Linux
0:34
distributions Oracle jdk is the Oracle
0:37
official Java distribution which
0:39
includes additional performance
0:42
optimizations and Commercial features it
0:44
is often required for the Enterprise
0:47
applications now we know the difference
0:49
let's get started the first step is to
0:52
install all the available updates for
0:55
that log into your obuntu system open
0:57
the terminal run the command sudu
1:10
upgrade i y h enter this command will
1:15
take 3 to 4 minutes depending upon your
1:32
once all the updates are installed then
1:34
we will move to the open jdk
1:35
installation open jdk package and its
1:38
dependencies are available in the
1:40
default package depositories of open to
1:43
24.4 so it installation is
1:46
straightforward let me clear the screen
1:48
first and run the command sud do space
1:51
app space install space default hyphen
2:01
so this command will install open jdk 21
2:05
LTS which is officially supported
2:17
enter after the installation verify the
2:20
Java version with the
2:22
command Java space hyphen hyphen version
2:30
in the output we can clearly see we have
2:33
installed open zdk 21 in case you want
2:36
to install specific version of java
2:38
let's say Java 11 or Java 17 or Java 21
2:43
for that you need to run the
2:58
hyphen let's say I I want to install
3:00
Java 11 then typee here 11 then hyphen
3:04
jdk hyphen y so this command will
3:07
install Java 11 if you want to install
3:14
11 type 17 and for 21 in place of 17
3:19
type 21 let's assume I want to install
3:22
Java 11 as well so run this
3:37
if you need to install Oracle jdk then
3:40
first we need to download its debin
3:42
package from Oracle website in Google
3:46
search download Oracle
3:52
enter go to it official website
4:01
so at the time of creating this video
4:03
tutorial we have Java
4:10
package click on this
4:14
URL it will start downloading the Debian
4:17
package in your downloads folder once
4:21
completed go back to your
4:26
terminal go to the downloads folder
4:32
and if you do LS here you will get this
4:34
dein package in order to install this uh
4:37
Oracle zdk we need to run the
5:00
now if you run the command Java space
5:02
hyphen version you should see uh Java
5:12
23 great the output confirms that we
5:15
have installed Java 23 which is Oracle
5:18
jdk as you know we have installed
5:21
multiple Java versions on our obuntu
5:23
system now we will see how to configure
5:26
the default Java version for that we can
5:29
run the command update hyphen
5:32
command complete Command would be sud do
5:40
Alternatives space hyphen hyphen config
5:46
enter let's suppose I want to set this
5:49
Java 21 as my default Java for that
5:53
select the number so for Java 21 we need
6:02
enter and if you rerun the Java version
6:06
command you should see that default Java
6:09
version is open ZK 21 next set Java unor
6:14
home environment variable in order to
6:16
set this environment variable first we
6:19
need to find Java installation path if
6:22
you see the output of update alternative
6:25
space hyphen config Java command output
6:28
you will see the path of different Javas
6:32
so for 21 this would be the installation
6:35
path so copy this path till AMD
6:52
environment Define a variable
7:05
that installation path you have just
7:14
file in order to make the changes into
7:16
the effect we need to Source this file
7:19
and the command Source space
7:24
environment verify that Java uncore home
7:27
is set correctly or not you can run the
7:30
command EOS space dollar Java uncore
7:36
home great output confirms that we have
7:41
a environment variable javore home whose
7:47
one before compiling any Java program
7:50
make sure both Java and Java
7:53
compilers are pointing to the same Java
7:56
version in order to change the Java
8:02
version Let run this command
8:07
again use Java C and hit
8:17
enter type two here and hit enter now
8:21
that Java is installed let's write a
8:23
sample Java program to test our setup
8:25
create a file with the name hello world.
8:36
here is the sample code save and close
8:40
file now compile this program using the
8:51
Java now run the program with the
9:00
great our program is executed
9:03
successfully I can see the
9:06
output that's it you have successfully
9:08
installed Java on your OB to2
9:11
24.4 and you have tested a sample hello
9:13
world program now you are ready to start
9:16
developing Java applications if you
9:18
found this tutorial helpful do not
9:20
forget to like subscribe and hit the
9:22
notification Bell for more Linux
9:24
tutorials let us know in the comments
9:27
which Java version you are using thanks
9:29
for watching watching see you in the