Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between JRE and JVM

 
Abhijeet Pathak
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me the exact difference between JRE and JVM?
If Java is platform independent language,then why do we need a JRE for running JAVA programs?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java code is compiled to the machine language of an idealized computer called the Java Virtual Machine (JVM). To run Java code on a real computer, you need a program that implements the imaginary computer. The program "java.exe" is such a program.

The Java Runtime Environment (JRE) is a JVM, plus the various libraries of class files and their native code that are needed to support the full Java API. The file java.exe by itself is not actually enough to run a Java program -- you need a full JRE.

Regarding platform independence: Java bytecode will run on any JRE. You can implement the JRE on virtually any real computer, and this makes Java code binary compatible across all those platforms.


 
Campbell Ritchie
Sheriff
Posts: 48424
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can compare it to a car: The JVM (Java Virtual Machine) is the motor. But if you want to go anywhere, you need more than just a motor. The JRE (Java Runtime Environment) is the complete car, including the motor. So to run Java programs, you need a JRE, and not only a JVM.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic