File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Difference between JRE & JVM 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 JRE & JVM" Watch "Difference between JRE & JVM" New topic

Difference between JRE & JVM

Srikantha Reddy Lankireddy

Joined: Aug 30, 2007
Posts: 2
Sorry for starting the same old topic again... I searched on Internet, got some answers and more doubts.

What is the difference between JVM and JRE?

�Is JVM used to convert java file into byte code, and JRE is for interpreting that byte code as machine dependent binary code and executing that code?

I came to know it is not correct, when I searched Net to know answer for this question.

�If JVM & JRE, both are for interpreting and executing the byte code on a specific platform only, what are their respective duties?

1.Which performs Array bounds checking (JVM or JRE)?
2.Which restricts the program from doing malicious operations?

To run your application, a user needs a Java virtual machine, the Java platform core classes, and various support programs and files. This collection of software is known as a runtime environment.
(From )

From above information, I am thinking that JVM only interprets the byte code and executes that and performs other things like garbage collection, bounds checking, etc.
And JRE is just a name given for the combination of JVM + library classes + and other supporting files. Is my assumption correct?

From this I am having another doubt; doesn�t the library classes (that we import into our program) become a part in our program when the program is converted into byte code? If they are outside to our program always, what does �imports� mean? I mean it should import the library classes we referred into our program� doesn�t it?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199


Welcome to JavaRanch!

Your final description of JVM vs. JRE is correct.

Each class is always stored in a separate .class file. "import" does not add the library classes to your code; it just tells the compiler how to decide which classes your code refers to. So, for example, if you write a program that uses a class named "Date", you need to say

import java.util.Date;


import java.util.*;

or the compiler won't know that you mean java.util.Date, instead of some other class also named Date (like java.sql.Date, for example.)

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Difference between JRE & JVM
It's not a secret anymore!