If you are a Java developer and you are going to achieve success in Java, it is very important to have clear understanding and know difference between main Java components . This knowledge will give you overall picture of what Java is, how it works and definitely will help you in developing applications.
Firstly, I would like to show you all main components in one diagram. On the diagram below you will find information on how the components related to each other and which components are parts of other components.
For instance, you can see that Java Development Kit JDK includes all components . The Java Virtual Machine JVM includes Just-In-Time compiler JIT and core libraries. In fact, you can install only JRE without development tools, but in this case you will not be able to compile Java code to byte code.
Another diagram that I wanted to show, is “workflow” diagram on which I have illustrated the path that passes typical Java application.
In this path the application faces with all main java components. For example, to create any Java application we need to create a source code file that contains Java language commands. The source file must be compiled into byte code via compiler that is a part of JDK. Once the byte code is ready we can execute application using JRE.
The sections below describe all mentioned above components in details.
What is JVM?
Java Virtual Machine is a specification that defines an abstract machine in which java byte code can be executed. The specification describes instruction set, stacks, a set of registers, method area, heap and it omits implementation details to ensure interoperability. Thus, the same Java byte code can be executed on variety platforms such as Windows or Linux “compile once, run anywhere”.
The specification can be changed via special process which is called Java Community Process JCP.
What is JRE?
In fact, when we are talking about JVM we may think about three different things: specification, implementation or instance. The Java Runtime Environment is an implementation of the JVM specification. It physically exists and contains libraries that can be used in runtime.
Once you execute Java application, the instance of the JVM will be created. When application completes, the instance dies. Thus, if run two applications, then two instance of JVM will be created.
Hotspot is a oficial JVM implementation distributed by Oracle.
What is JIT?
Just-in-time compiler is a part of JVM it compiles byte code into machine code on the fly, which gives a performance boost. Because, a running application can contain thousands of byte code files and it will take a lot of resources to keep and work with all these files in memory. So – the main difference between JIT and traditional compilers is that JIT compiles code on demand, the traditional compilers compile code once.
What is JDK and OpenJDK?
JDK is a freeware tool kit for java application development. It contains compiler (javac), debugger, standard libraries, examples, documentation, variety utilities and Java Runtime Environment. But, it doesn’t include IDE, so that the developer can use text editor and command line to run utilities.
OpenJDK is a open source development kit with all the ensuing consequences. In fact, OpenJDK was slower up to Java 6. Today, there is no big difference between to of them, they are both very good supported.