Wednesday, July 29, 2015

JVM, JRE and JDK

http://javatipseveryday.com - Discover the Secrets to Become a Java Expert in 365 days!
Hi friends, Today I’m going to talk with you about the 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: JVM JRE 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.

4. Where to download JRE and JDK?

The starting point is java.oracle.com, but you can go directly to this: http://www.oracle.com/
technetwork/java/javase/downloads/index.html.


Thursday, December 29, 2011


Difference between JRE JVM and JDK in Java Programming language

JRE, JVM and JDK are three terms you often heard in conjunction with Java programming language and most people either confuse between them or think they all are same. In this java article we will what is Java Run-time (JRE), what is Java virtual Machine (JVM) and what is Java development Kit (JDK) along with Just in Time compiler or JIT. Once you know what JRE, JVM or JDK means you can differentiate them easily by yourself.  This article is in continuation of Difference between Comparable and Comparator in Java and Difference between ConcurrentHashMap and Synchronized-map.

JRE JVM and JDK in Java Programming language

Java Runtime Environment (JRE)

Difference between JVM JRE and JDK in Java Programming languageJava is every where in browser, in mobile, in TV or in set-top boxes and if you are into Java programming language than you know that Java code which is bundled in JAR (Java archive) file require Java virtual machine JVM to execute it. Now JVM is an executable or program like any other program and you can install that into your machine. You have seen browser often suggesting download JRE to run a Java Applet downloaded from Internet. Various version of JRE are available in java.oracle.com and most of the user who just want to execute Java program inside browser or standalone downloads JRE. All browsers including Internet Explorer, Firefox and Chrome can work with JRE.

Java Virtual Machine (JVM)

When you download JRE and install on your machine you got all the code required to create JVM. Java Virtual Machine is get created when you run a java program using java command e.g. java HelloWorld. JVM is responsible for converting byte code into machine specific code and that's why you have different JVM for Windows, Linux or Solaris but one JAR can run on all this operating system. Java Virtual machine is at heart of Java programming language and provide several feature to Java programmer including Memory Management and Garbage Collection, Security and other system level services. Java Virtual Machine can be customized e.g we can specify starting memory or maximum memory of heap size located inside JVM at the time of JVM creation. If we supplied invalid argument to java command it may refuse to create Java Virtual Machine by saying "failed to create Java virtual machine: invalid argument". In short Java Virtual Machine or JVM is the one who provides Platform independence to Java.

Java Development Kit (JDK)

JDK is also loosely referred as JRE but its lot more than JRE and it provides all the tools and executable require to compile debug and execute Java Program. Just like JRE, JDK is also platform specific and you need to use separate installer for installing JDK on Linux and Windows. Current Version of JDK is 1.7 which is also referred as Java7 and it contains javac (java compiler) based on programming rules of Java7 and Java which can execute java7 code with new features like String in Switch, fork-join framework or Automatic Resource Management. When you install JDK, installation folder is often referred as JAVA_HOME. All binaries are located inside JAVA_HOME/bin which includes javac, java and other binaries and they must be in your system PATH in order to compile and execute Java programs. For details on Path see how to set PATH for Java in Windows and UNIX.

Difference between JRE, JDK and JVM

In short here are few differences between JRE, JDK and JVM:
1)  JRE and JDK come as installer while JVM are bundled with them.
2)  JRE only contain environment to execute java program but doesn’t contain other tool for compiling java program.
3)  JVM comes along with both JDK and JRE and created when you execute Java program by giving “java” command.

Just in Time Compiler (JIT)

Initially Java has been accused of poor performance because it’s both compiles and interpret instruction. Since compilation or Java file to class file is independent of execution of Java program do not confuse. Here compilation word is used for byte code to machine instruction translation. JIT are advanced part of Java Virtual machine which optimize byte code to machine instruction conversion part by compiling similar byte codes at same time and thus reducing overall execution time. JIT is part of Java Virtual Machine and also performs several other optimizations such as in-lining function.
That’s all on JRE, JDK and Java Virtual machine and difference between them. Though they look similar they are different and having a clear idea of JVM, JIT or JDK helps in java programming.
Java Tutorial you may like:

1 comment:

  1. I think that this is simple.
    JRE = JVM + standard classes
    JDK = JRE + development tools (compiler, debugger, etc)
    I suggest to check this tutorial that explains the difference between jvm, jre and JDK :
    http://how-to-program-in-java.com/2016/08/11/jvm-vs-jre-vs-jdk-difference-beginners/

    ReplyDelete