[java] What is the difference between JVM, JDK, JRE & OpenJDK?

What is the difference between JVM, JDK, JRE & OpenJDK?

I was programming in Java and I encountered these phrases, what are the differences among them?

This question is related to java jvm difference

The answer is


JVM : virtual machine of java. tells machine what to do with the Java Code. You cannot download JVM as is. It comes packaged in some other component.

JRE: Some other component referred as above is the JRE. It is JVM+ other jars to create runtime environmeny

JDK: contains JRE(which in turn contains JVM). Once you get JDK you need not install JRE and JVM separately. It contains compiler which compiles your .java files to .class files


JDK (Java Development Kit) :

  • contains tools needed to develop the Java programs.
  • You need JDK, if at all you want to write your own programs, and to compile them.
  • JDK is mainly targeted for java development.

JRE (Java Runtime Environment)

Java Runtime Environment contains JVM, class libraries, and other supporting files. JRE is targeted for execution of Java files.

JVM (Java Virtual Machine)

The JVM 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… Java Virtual Machine provides a platform-independent way of executing code.


JVM : this actually means the byte code interpreter .It is platform dependent. For eg: in Windows platform the 'java.exe' or 'javaw.exe' precess is the jvm process.

JDK : is a toolkit containing necessary libraries and utilities to develop and execute java program/application

JRE: is the execution environment for a java application.ie, it only support runtime dependencies including jvm for compiled program. If we want to compile a java program we need jdk.


Another aspect worth mentioning:

JDK (java development kit)

You will need it for development purposes like the name suggests.

For example: a software company will have JDK install in their computer because they will need to develop new software which involves compiling and running their Java programs as well.

So we can say that JDK = JRE + JVM.

JRE (java run-time environment)

It's needed to run Java programs. You can't compile Java programs with it .

For example: a regular computer user who wants to run some online games then will need JRE in his system to run Java programs.

JVM (java virtual machine)

As you might know it run the bytecodes. It make Java platform independent because it executes the .class file which you get after you compile the Java program regardless of whether you compile it on Windows, Mac or Linux.

Open JDK

Well, like I said above. Now JDK is made by different company, one of them which happens to be an open source and free for public use is OpenJDK, while some others are Oracle Corporation's JRockit JDK or IBM JDK.

However they all might appear the same to general user.

Conclusion

If you are a Java programmer you will need JDK in your system and this package will include JRE and JVM as well but if you are normal user who like to play online games then you will only need JRE and this package will not have JDK in it.

In other words JDK is grandfather JRE is father and JVM is their son.


In summary:

  • JRE = JVM + Java Packages (like util, math, lang, awt, swing etc) + runtime libraries
  • JDK = JRE + Development/debugging tools

If you want to develop in java, you need the JDK, but if you just want run java, you need the JRE.


JVM : A specification which describes the the way/resources to run a java program. Actually executes the byte code and make java platform independent. In doing so, it is different for different platform. JVM for windows cannot work as JVM for UNIX.

JRE : Implementation of JVM. (JVM + run time libraries)

JDK : JRE + java compiler and other essential tools to build a java program from scratch


JVM Java Virtual Machine , actually executes the java bytecode. It is the execution block on the JAVA platform. It converts the bytecode to the machine code.

JRE Java Runtime Environment , provides the minimum requirements for executing a Java application; it consists of the Java Virtual Machine (JVM), core classes, and supporting files.

JDK Java Development Kit, it has all the tools to develop your application software. It is as JRE+JVM

Open JDK is a free and open source implementation of the Java Platform.


In layman terms:- JDK = JRE + Development/debugging tools, where JDK is our complete package to work with Java, from creating compiling till running it.On the other hand JRE is just of running of code(Byte Code).

Note:- Whether we are installing JDK or JRE, JVM would come bundled with both the packages and JVM is the part where JIT compiler converts the byte code into the machine specific code.

Just read the article on JDK,JRE ,JVM and JIT


JRE executes the application but JVM reads the instructions line by line so it's interpreter.

JDK=JRE+Development Tools

JRE=JVM+Library Classes


JDK: The complete package which you need to write and run java code

OpenJDK: An independent implementation of JDK for making it much better

JVM: Converts Java code into bytecode and provides the specifications which tells how should a Java code be compiled, loaded, verified, checked for errors and executed.

JRE: Implementation of the JVM with which some Java libraries are used to Run the program


JVM is abbreviated as Java Virtual Machine, JVM is the main component of java architecture. JVM is written in C programming language. Java compiler produce the byte code for JVM. JVM reading the byte code verifying the byte code and linking the code with the ibrary.

JRE is abbreviated as Java Runtime Environment. it is provide environment at runtime. It is physically exist. It contain JVM + set of libraries(jar) +other files.

JDK is abbreviated as Java Development Kit . it is develop java applications. And also Debugging and monitoring java applications . JDK contain JRE +development tools(javac,java)

OpenJDK OpenJDK is an open source version of sun JDK. Oracle JDK is Sun's official JDK.


JVM

JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed. JVMs are available for many hardware and software platforms.

JRE

JRE is an acronym for Java Runtime Environment.It is used to provide runtime environment.It is the implementation of JVM.It physically exists.It contains set of libraries + other files that JVM uses at runtime.

JDK

JDK is an acronym for Java Development Kit.It physically exists.It contains JRE + development tools.

Link :- http://www.javatpoint.com/difference-between-jdk-jre-and-jvm


Java is the language and includes a strict and strongly typed syntax with which you should be very familiar by now.

Java 2 Platform, Standard Edition, also known as J2SE, referred to the platform and included the classes in the java.lang and java.io packages, among others. It was the building block that Java applications were built upon.

A Java Virtual Machine, or JVM, is a software virtual machine that runs compiled Java code. Because compiled Java code is merely bytecode, the JVM is responsible for compiling that bytecode to machine code before running it. (This is often called the Just In Time Compiler or JIT Compiler.) The JVM also takes care of memory management so that application code doesn’t have to.

The Java Development Kit, or JDK, was and remains the piece of software Java developers use to create Java applications. It contains a Java language compiler, a documentation generator, tools for working with native code, and (typically) the Java source code for the platform to enable debugging platform classes.

The Java Runtime Environment, or JRE, was and remains the piece of software end users download to run compiled Java applications. It includes a JVM but does not contain any of the development tools bundled in the JDK. The JDK, however, does contain a JRE.


JDK - Compiles java to ByteCode. Consists of debuggers, Compilers etc.

javac file.java // Is executed using JDK

JVM - Executes the byte code. JVM is the one which makes java platform independent. But JVM varies for platforms.

JRE - JVM along with java runtime libraries to execute java programs.


JVM is the Java Virtual Machine – it actually runs Java ByteCode.

JRE is the Java Runtime Environment – it contains a JVM, among other things, and is what you need to run a Java program.

JDK is the Java Development Kit – it is the JRE, but with javac (which is what you need to compile Java source code) and other programming tools added.

OpenJDK is a specific JDK implementation.


A Java virtual machine (JVM) is a virtual machine that can execute Java ByteCode. It is the code execution component of the Java software platform.

The Java Development Kit (JDK) is an Oracle Corporation product aimed at Java developers. Since the introduction of Java, it has been by far the most widely used Java Software Development Kit (SDK).

Java Runtime Environment, is also referred to as the Java Runtime, Runtime Environment

OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java programming language. It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License (GPL) with a linking exception.


JVM is the virtual machine Java code executes on

JRE is the environment (standard libraries and JVM) required to run Java applications

JDK is the JRE with developer tools and documentations

OpenJDK is an open-source version of the JDK, unlike the common JDK owned by Oracle


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 them. 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

The Java Virtual Machine provides a platform-independent way of executing code; That mean compile once in any machine and run it any where(any 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.


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to jvm

Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 How can I get a random number in Kotlin? Kotlin unresolved reference in IntelliJ Is JVM ARGS '-Xms1024m -Xmx2048m' still useful in Java 8? Android Gradle Could not reserve enough space for object heap Android java.exe finished with non-zero exit value 1 Android Studio Gradle project "Unable to start the daemon process /initialization of VM" Android Studio - No JVM Installation found Android Studio error: "Environment variable does not point to a valid JVM installation" Installing Android Studio, does not point to a valid JVM installation error

Examples related to difference

Calculate time difference in minutes in SQL Server Java 8: Difference between two LocalDateTime in multiple units Differences between Oracle JDK and OpenJDK Android difference between Two Dates Difference between IsNullOrEmpty and IsNullOrWhiteSpace in C# Get the time difference between two datetimes What is the difference between JVM, JDK, JRE & OpenJDK? What is the difference between bottom-up and top-down? What's the difference between ViewData and ViewBag?