JDK, JRE, JVM.
Three acronyms that can strike fear into
the heart of any budding Java developer.
Well maybe not fear but it's certainly confusing.
So let's have a talk about it and figure out
what these three acronyms are all about.
This video is brought to you by
the Learning Programme Academy's Java Masterclass.
With 77 hours of video training,
320 thousand students and tens of thousands
of glowing reviews, this truly is
the best way to learn Java.
Grab a massive discount and instant access
by visiting lpa.dev/YoutubeJava
or by clicking on the link in the description of this video.
(upbeat music)
Welcome back, my name is Tim Buchalka
with another programming tip of the day.
We're talking about the JDK, the JRE
and the JVM and we're going to come to you
and find out, hopefully by the end of the video,
what they all mean.
So let's start with the JDK.
Well the JDK stands for the JAVA Development Kit.
And it's basically just that.
It's the development kit that you need
to create Java programmes.
There's a version for both Windows, Mac and Linux.
Basically it's the tools that will take your Java
source code, the code that you write,
and convert them into a format that the JRE and the JVM,
which we'll talk about shortly, can execute.
So it includes things like debuggers for testing
and for finding errors in your code
but also the Java Compiler for compiling that code.
So that's the Java Development Kit.
So moving on, the next one is the JRE
and JRE stands for the Java Runtime Environment.
So firstly, the Java Runtime Edition,
the JRE action includes the JVM,
which is the Java Virtual Machine
but we'll talk more about the JVM
a little bit later in the video.
So what's included in the JRE
and in fact, what's it all about?
Well the JRE, because you probably guessed by
the word Runtime in the Java Runtime Environment,
is used to run your Java programme.
So basically includes the libraries,
set of different libraries that come with Java,
the various functionality that you can basically execute
in your Java code but also Java Launcher
and I've mentioned, it also includes
the Java Virtual Machine.
And there's a version for that for Windows, Mac and Linux
as well and interestingly enough,
the Java Development Kit comes bundled
with a Java Runtime Edition as well.
Now in previous versions that wasn't the case
and as a developer, you would have to have installed
both versions on your computer
but that's no longer the case.
So basically with the Java Runtime Environment,
any person who wants to run Java code,
has to have the Java Runtime Edition installed
on their computer to do so.
Now the Java Runtime edition, just to be clear,
doesn't include any development tools.
So you can't develop programmes
with the Java Runtime Environment,
you actually run the code that is created,
if with the tools of the Java Development Kit,
using the Java Runtime Edition.
All right, so moving on, now before I start talking
about the Java Virtual Machine,
which is what the JVM stands for,
you need to have a bit of an understanding
how tradition computer programming languages work.
Now we take the example of C++.
Now C++ Compiler, which compiles your C++ code,
compiles it into the hardware or it makes it work
with the hardware that it is currently being compiled on.
So if you're running a C++ Compiler
on your Windows Intel machine, it'll create a version,
an executable version of the code,
that'll execute only on an Intel platform computer.
You won't be able to take that executable code
and run it on a different architecture machine
like a Solaris unit machine for example.
So that's how traditional programming language
is like a C++ virtually compile programmes into that format.
Now Java takes a different approach.
The Java Virtual Machine, and this is part of
the Java Runtime Environment,
that's effectively an abstract computing machine.
That's really what it is.
And the Java Virtual Machine, the JVM,
knows nothing about the Java programming language.
All it knows that all it can do
is work with compiled Java code.
So essentially the Java Virtual Machine
is more or less like a physical machine,
but it's an abstract concept.
So it's a virtual machine that runs on your computer
so when you actually execute a programme
from the Java Runtime Environment,
it runs this virtual machine.
That's how you code's actually executed.
And that probably sounds a bit confusing
but essentially the Java Development Kit creates
or takes the Java code that you've written
and creates this class files, .class files
and you may have seen those
when you've been working with Java.
And those class files are actually executed
or can be executed by the Java Virtual Machine.
So that's basically the process
the Java Development Kit takes the Java code
that you've typed into your typical editor or IDE
such as an Intellij, creates a class file, a .class file,
that class file can be executed via
the Java Runtime Environment in the Java Virtual Machine.
And that's to mention that the Java Virtual Machine
is bundled with the Java, with the JRE,
the Java Runtime Environment.
Now in terms of the Java Runtime Edition on the JVM,
that runs on many devices.
So basically what happens is, a manufacturer or vendor,
someone who creates an operating system or whatever,
they will actually produce a version
of the JAVA Virtual Machine based on
the specifications that I could have available
and as soon as they do that
and they implement that Java Virtual Machine,
that means you can take your Java code
and run it on their virtual machine.
So this is how Java achieves
the ability to run on so many different devices
and so many operating systems, it's running
a different Java machine which has been written
for that particular operating system or machine,
the hybrid as well.
So I think that's a pretty interesting concept
of how Oracle and actually Sun because they were
the original creators of the Java product,
how they built this concept of a virtual machine
and from there you're running your code
in a virtual machine and therefore
it can run on any device or any operating system
that actually has a version of the Java Virtual Machine,
are very widely used out in the industry.
All right, so that's really the concept.
Now one other thing I'd like to address
before we finish the video, is the slowness.
'Cause if you think about it, C++ code
is an example that produces native code.
So in other words when you compile the code,
it produces a version of that code that runs
on that specific hardware and there's no obstruction layer.
So its basically straight into that hardware
and that's how C++ is actually going to run faster
in general but a Java programme,
and again, that's because a Java programme is working
on a Java Virtual Machine, so it's basically abstract
in that concept the Java Virtual Machine
is then producing the machine code
that actually runs the actual code.
So you can see these a two-step process
with Java code as opposed to one step process
with a C++ executable.
So that's why, in the past, Java has been fairly slow
or known as fairly slow and if you do any research
you'll se that a lot of people still think
that Java is extremely slow.
But in general, Java is now a lot, lot faster.
Couple of reasons, firstly there's a lot of efficiencies
in optimizations that've gone on in Java Virtual Machines
over that last probably 20, 25 years that Java's been around
but secondly computer hardware these days,
is so much faster and so much more powerful
that's really making the fact that it's a virtual machine
running almost a non-issue.
So if you're worried about Java being slower
than perhaps traditional programming languages,
more or less that feature has gone away
and it's really only things like,
your really intensive graphical applications,
games and those sorts of things
that you'll really notice the performance differences
between say C++, which is a common language
for that sort of, those sort of applications, and Java.
Right, so that's basically it, that's the overview.
So hopefully now you understand
the differences between the JDK, Java Development Kit,
Java Runtime Environment, JRE and the JVM,
Java Virtual Machine.
All righty, so I hoped that helped.
If you've got any questions, feel free to leave a comment
and I'll get back to you.
If you're ready to look at the next tip,
click on up here
and you can check that out.
If you're interested in coding specific programming videos,
click on that link in the bottom left hand corner.
Consider subscribing by clicking on the link up here
and I'll see you soon.