• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between JVM and JRE !!

 
Parth Bhatt
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !!

Just ran in to a bit of confusion figuring out what is the exact diference between JVM and JRE.

I mean, A JVM is a VIRTUAL MACHINE, that sits on top of your Software Platform and Simulates the characteristics of the underlying hardware/software. A JRE on the otherhand is the execution environment that a Java Program executes within... If This is correct then Is a JRE built into a JVM ? Also provide better explanation about JVM and JRE...

Can Somebody help me out on this plz...!!
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JVM is just the "bare machine" -- the thing that executes .class files.

A JRE includes libraries and APIs (i.e., all the java.* and javax.* Java classes, plus things like the native libaries needed for the AWT to function.) So a JRE is a JVM plus more stuff.

You can't actually run a program on a bare JVM; there are a few APIs (the java.lang package, in particular) which the JVM can't function without.

A JDK (or J2SDK, as they used to call it) is a JRE plus all the development tools like javac, javap, rmic, etc.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JVM is part of the JRE. As EFH, the JRE also includes the standard Java API that is necessary to run any Java program.

Layne
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15452
42
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a frequently asked question, you could have found the answer quickly by searching the forum...

Try this analogy.

The JVM is the engine.
The JRE is the complete car, including the engine.

The car (JRE) is not built into the engine (JVM), but the other way around.
 
Parth Bhatt
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okey...!! That solves my confusion to a great deal....!! Thanks a TON guys!!
 
viswanath rai
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JVM is an application.
Where as JRE is JVM+All classes loaded i.e., JVM with initialization is known as JRE.
On one machine we can initialize any number of JVMs.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49849
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Viswanath Rai. I think you have understood the problem correctly, and yes, you can run several JVMs simultaneously.
 
abhinav sinha
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had confusions regarding the JRE and JVM and I found this thread here. I have JDK 1.6 installed on my system. What will "javac -target 1.5" do? Will the compiled code run on a machine with JRE 1.5 ?
[ December 02, 2008: Message edited by: abhinav sinha ]
 
Campbell Ritchie
Sheriff
Pie
Posts: 49849
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't reopen such an old thread, particularly since this is a new question.
I am not sure, but I think that will mean it will run on a JDK5 machine, yes, but you need to ensure you don't use any classes or methods introduced in Java6 otherwise you will get a NoSuchMethodError or similar.

Best to try a tiny application and see what happens.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic