Last Updated on 26 August 2019   |   Print Email
In this article, you will understand the differences among JVM, JRE and JDK. As a Java programmer, you should understand these basic stuffs clearly. It’s like you should see the characteristics and personality of your girlfriend or partner.
1. What is JVM?
JVM stands for Java Virtual Machine. It is an abstract computing machine that is responsible for executing Java programs. When you write a Java program, the source code is compiled into byte code which is understandable by the JVM. Upon execution, the JVM translates byte code into machine code of the target operating system.The JVM is the cornerstone of the Java programming language. It is responsible for the very well-known feature of Java: cross-platform. That means you can write a Java program once and run it anywhere: Windows, Linux, Mac and Solaris, as long as JRE is installed on the host operating system.Every time you run a Java program, the JVM is started to execute and manage the program’s execution. The JVM is running in two modes: client (default) and server.An Oracle’s implementation for JVM is called Java HotSpot VM.
2. What is JRE?
JRE stands for Java Runtime Environment. It provides the libraries, JVM and other components necessary for you to run applets and applications written in the Java programming language.The JRE contains standard tools such as java, keytool, policytool,… but it doesn’t contain compilers or debuggers for developing applets and applications.
When you deploy your Java applications on client’s computer, the client needs a JRE to be installed.
3. What is JDK?
JDK stands for Java Development Kit. It’s a superset of JRE. The JDK includes the JRE plus command-line development tools such as compilers (javac) and debuggers (jdb) and others (jar, javadoc, etc) that are necessary or useful for developing applets and applications.Therefore, as a Java programmer, you have to install JDK as a minimum requirement for the development environment.To summary:
JVM: is the virtual machine that runs Java applications. The JVM makes Java platform-independence.
JRE = JVM + standard libraries: provides environment for executing Java applications.
JDK = JRE + development tools for compiling and debugging Java applications.
The following picture depicts the relationship among JVM, JRE and JDK:Okay, so far I have covered the basic information about the 3 cornerstones in Java programming: JVM, JRE and JDK. I hope you are now able to identify the differences among these components.And here are some tips:
You should have both JRE and JDK installations (setup) on your computer. You will need both during the development process.
You should have multiple versions of JDK and JRE installed: 1.5, 1.6, 1.7 and 1.8 for different testing purposes in the future.
You should install both 32-bit and 64-bit versions.
When installing the JDK, remember to check ‘Install Demos and Samples’. Then you can explore various interesting examples in the demo directory under JDK’s installation path.
Only the JDK includes source code of the Java runtime libraries. You can discover the source code in the src.zip file which can be found under JDK’s installation directory.
That's the difference among JVM, JRE and JDK in Java. You will dive into these stuffs along the way of your Java programming journey. And today is good for the beginning.
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.
Comments