• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between JRE & JVM  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 http://java.sun.com/j2se/1.3/jre/README )

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?
author and iconoclast
Posts: 24217
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!