Want this course?
Understanding the abbreviations of the Java world—JVM JRE JDK
Course: JVM Fundamentals for Clojure
Ever get confused with what the JVM, JRE, and JDK are and what are in them? This lesson runs through these abbreviations. They're actually easier than they sound.
The JVM. We work on it all the time in Clojure and so it's important to understand all those acronyms and JREs, the alphabet soup that we deal with all the time.
So we're gonna go through the parts of the JVM, the JDK, the JRE, all those, right now. Okay, it's actually super easy, so this will probably be a really short episode, so let's take a look.
So in the middle there's the JVM. There's two parts to the JVM. The classloader, which is what searches for class files and there's no real spec for how those class files will be searched for, but each JVM is allowed to do it however it feels like it. There has been kind of a defacto way that it's done, which we'll go into when we're talking about where to put your class files, the class path, that kinda thing. But it has to have a classloader so that it can load in the class files.
And class files contain bytecode. So the JVM also has a bytecode interpreter. This is how the JVM achieves that write once, run anywhere that it's trying to achieve. It abstracts away the machine code and has a bytecode interpreter. Now, the bytecode interpreter is a really complex thing. That's where a lot of the research and innovations have come from. And usually, it's not a strict interpreter, it's got a JIT. So it will compile the bytecode into machine code as it's running. So that's the JIT, that means just-in-time compiler. And it only does that when it needs to, so it's kind of efficient.
Now, the JVM was created by Sun Microsystems, but now it's owned and maintained by Oracle because Oracle bought Sun. So JVM is an Oracle thing. There's a spec and everything for how the JVM works and surprisingly, the JVM has stayed very stable. It's been a very good base for building on top of. For instance, the bytecodes are all backwards compatible and they've only added a few in like, 20 years. So it's a very stable platform.
Okay, so then there's the JRE, which contains the JVM. I'm trying to put some circles here to show containment. And this is basically the JVM plus all the Java class libraries that come with it. So, all the standard libraries, all the classes that are like, built into the language, the java.lang, all of the external things that might come with it, like you might have a JDBC included in your JRE. And this one is more variable, obviously, because it's got all this code that comes along with it. All this software. But there's the JRE Standard Edition and it's got the whole Java language, all the classes and everything that you need for that.
Okay, finally, come over here, there's the JDK. So if you're gonna be develop-- Oh, did I mention JRE stands for Java Runtime Environment? The JDK is the Java Development Kit. And it contains all of this stuff, the whole JRE, plus a bunch of development tools. Now most people won't need these on their machine. They will need the JRE. But they don't need a compiler and stuff, because most people aren't writing software. But the JDK does have the development tools that we want, such as the javac, which is the Java compiler. The javadoc tool, which will take Java source code and generate HTML documentation. Profilers, stuff for hooking into the running JVM to see what's going on, those kinds of development tools. And documentation. Of course, there's probably other stuff in there, but these are the main things that comprise the JDK.
So those are the parts. JVM, Java Virtual Machine. Very, the core of it, this is what runs the bytecode. The JRE has all the standard libraries in it, and then the JDK has all the developer tools.