wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Difference between JVM and JRE !! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between JVM and JRE !!" Watch "Difference between JVM and JRE !!" New topic
Author

Difference between JVM and JRE !!

Parth Bhatt
Ranch Hand

Joined: Oct 19, 2005
Posts: 58
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...!!


If your new Big Idea doesn't scare the hell out of you, <br />it's probably not a "new Big Idea".
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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


Java API Documentation
The Java Tutorial
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Parth Bhatt
Ranch Hand

Joined: Oct 19, 2005
Posts: 58
Okey...!! That solves my confusion to a great deal....!! Thanks a TON guys!!
viswanath rai
Greenhorn

Joined: Jan 16, 2008
Posts: 1
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

Joined: Oct 13, 2005
Posts: 38481
    
  23
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

Joined: Nov 29, 2007
Posts: 22
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

Joined: Oct 13, 2005
Posts: 38481
    
  23
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between JVM and JRE !!