What is the difference between JRE,JVM and JDK?

If you are a Java developer, it is very often that you think about understanding the JRE,JVM and JDK. Once if you understand these things, it would be quite easy for you to visualize things in logical manner. Also look at the picture below, that will clear all your questions about the JRE,JVM and JDK. This article explains about the each term and will make you understand perfectly. Hope this helps. If you are happy to receive our future updates on Java, please subscribe here.

JDK (Java Development Kit)

Java Developer Kit contains tools needed to develop the Java programs, and JRE to run the programs. The tools include compiler (javac.exe), Java application launcher (java.exe), Appletviewer, etc… Compiler converts java code into byte code. Java application launcher opens a JRE, loads the class, and invokes its main method.

You need JDK, if at all you want to write your own programs, and to compile the m. For running java programs, JRE is sufficient. JRE is targeted for execution of Java files i.e. JRE = JVM + Java Packages Classes(like util, math, lang, awt,swing etc)+runtime libraries. JDK is mainly targeted for java development. I.e. You can create a Java file (with the help of Java packages), compile a Java file and run a java file.

JRE (Java Runtime Environment)

Java Runtime Environment contains JVM, class libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. Actually JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system

JVM, JRE and JDKThe Java Virtual Machine provides a platform-independent way of executing code; programmers can concentrate on writing software, without having to be concerned with how or where it will run. But, note that JVM itself not a platform independent. It only helps Java to be executed on the platform-independent way. When JVM has to interpret the byte codes to machine language, then it has to use some native or operating system specific language to interact with the system. One has to be very clear on platform independent concept. Even there are many JVMs written on Java, however hey too have little bit of code specific to the operating systems. 

If u just want to run applets (ex: Online Yahoo games or puzzles), JRE needs to be installed on the machine.

JVM (Java Virtual Machine)

As we all aware when we compile a Java file, output is not an ‘exe’ but it’s a ‘.class’ file. ‘.class’ file consists of Java byte codes which are understandable by JVM. Java Virtual Machine interprets the byte code into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc… JVM is platform dependent.

The JVM is called “virtual” because it provides a machine interface that does not depend on the underlying operating system and machine hardware architecture. This independence from hardware and operating system is a cornerstone of the write-once run-anywhere value of Java programs.

There are different JVM implementations are there. These may differ in things like performance, reliability, speed, etc. These implementations will differ in those areas where Java specification doesn’t mention how to implement the features, like how the garbage collection process works is JVM dependent, Java spec doesn’t define any specific way to do this.

Reference:

Recommended Books:

Comments

comments

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Comments

  1. out of jdk ,jvm,jre which is better

    • It is not about which is better, it all comprises of the Java platform. Each has its own purpose. If you read this article, you would have good idea.

    • It is not about which is better, it all comprises of the Java platform. Each has its own purpose. If you read this article, you would have good idea.

  2. out of jdk ,jvm,jre which is better

  3. out of jdk ,jvm,jre which is better

  4. SolMess says:

    Thank you, I just started reading Java today and copy pasted a sample program into an IDE and got confused, and you explained all my questions …. It was as if you read my mind

  5. sandeepbh says:

    this is the most comprehensive set of differences which I have come across. Thanks. very useful for interview purposes. Another good resource on the same lines is difference between JVM, JRE and JDK

  6. please correct:JVM is platform dependent.

  7. i really like is post… it helps me to overcome my confusion related to these things…

  8. i really like is post…
    it helps me to overcome my confusion related to these things

  9. Thanksgiving U so much sir

  10. In simple term JRE is the implementation of JVM .Jre exist physically while JVM is abstruct machine that does’t exist phycally.JDk comprise jre and other development tool like debugger ,compiler etc.

Trackbacks

  1. [...] 原文地址:http://www.javabeat.net/2013/02/what-is-the-difference-between-jrejvm-and-jdk/ [...]

  2. […] What is the difference between JRE,JVM and JDK? […]

  3. […] the basics of Java compiler and JVM architecture, please go through the articles Java Compiler API, JVM, JRE and JDK difference and […]

  4. […] If you are a Java developer, you must be very familiar with the build scripts and have good understanding on the various build tools like ant, maven, etc. We know that the main purpose of the build is too compile (Read : Java Compiler API) the source code to the executable form and then make the distributable archive file. In Java, source files are compiled to byte codes using the compiler and executed in the Java Runtime Environment (JRE). […]

  5. […] Bootstarap classloader is a native implementation. So, it could be different for each JVM […]

  6. […] Actually you can just suggest it to do the cleaning of a particular object, but it is not guaranteed that it will be done, It would be a big mistake by developing an application that relies heavily on the cleanliness of Garbage Collection. Java does not allow us to release objects in memory explicitly, for it has to be Garbage Collected. Let us now understand how this tool works and what are the advantages of having that “extra” feature offered by the JVM. […]

Speak Your Mind

*