top of page
  • Writer's pictureTim Buchalka

JDK, JRE, JVM: What Are They and What Are Their Differences?

Updated: Aug 2, 2019

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.

Today 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 this post, what they all mean.

Let's start with the JDK. Well, JDK stands for Java Development Kit and it's basically just that. It's the development kit that you need to create Java programs. 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. That's the Java Development Kit.

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. 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 program. It includes 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 as 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 programs 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. 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 traditional computer programming languages work.

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 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. That's how traditional programming language is like a C++ virtually compile programs 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.

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 program from the Java Runtime Environment, it runs this virtual machine. That's how your code's actually executed. That probably sounds a bit confusing but essentially the Java Development Kit creates or takes the Java code that you've written and creates these .class files and you may have seen those when you've been working with Java.

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. 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.

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 is the slowness. If you think about it, C++ code is an example that produces native code. 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 than a Java program, and again, that's because a Java program is working on a Java Virtual Machine. So it's basically abstract in a concept the Java Virtual Machine is then producing the machine code that actually runs the actual code.

So you can see that there's 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 but 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.

There's a couple of reasons: firstly, there's a lot of efficiencies in optimizations that have gone on in Java Virtual Machines over that last probably 20 to 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 those sort of applications, and Java.

All right so that's the overview. Hopefully, now you understand the differences between the JDK (Java Development Kit) Java Runtime Environment (JRE) and the JVM (Java Virtual Machine). So I hoped that helped. If you've got any questions, feel free to leave a comment and I'll get back to you.

32 views0 comments


bottom of page