What is the difference between JVM and JRE and JDK?

Hi , I want to know what actually is JVM,JRE and JDK ? and the difference between them?
[94 byte] By [deepakorsuna] at [2007-11-27 8:39:44]
# 1
If your fingers are broken and you can't google or wiki yourself, here ya go, on a spoon, ready to eat: http://en.wikipedia.org/wiki/JRE http://en.wikipedia.org/wiki/Jvm http://en.wikipedia.org/wiki/JDK
petes1234a at 2007-7-12 20:37:49 > top of Java-index,Java Essentials,New To Java...
# 2

> If your fingers are broken and you can't google or

> wiki yourself, here ya go, on a spoon, ready to eat:

>

> http://en.wikipedia.org/wiki/JRE

>

> http://en.wikipedia.org/wiki/Jvm

>

> http://en.wikipedia.org/wiki/JDK

Oh come on, that wasn't nice. Not everybody is able to answer their own questions. Java terminology can be confusing and difficult to understand in part because of all the acronyms used and all the name changes undergone by the various development kits and platforms.

But anyway, to answer your question deepakorsun, the JVM is the Java Virtual Machine and it is the abstract architecture of a machine (computer). It is called virtual because it is not an actual machine like an Intel based PC, but is run virtually (i.e. simulated or emulated) by software on a physical computer such as an Intel based PC. It is this theoretical machine which defines the structure of java .class files (java bytecodes). Java .class files are the conceptual equivalent of both ".exe" and ".dll" files on Windows. The difference is that an ".exe" files are executed by hardware whereas .class files are executed by software (in fact, the software that executes the .class files is called the JRE and is short for the Java Runtime Environment). The Java Runtime Environment is a native program (i.e. it is run by hardware) which provides the ability to execute java bytecodes (.class files) either by interpreting them or by translating them into the native instruction set of the computer. For example, java.exe, the java interpreter (part of the JRE) is a binary file which runs on Windows computers with an x86 (Pentium) processor. This native binary executable file, java.exe, is then used to execute a non-native file, say for example Program.class, which is a java bytecode class file. This example file Program.class is a binary executable program for the Java Virtual Machine (JVM) and will not run on a Windows x86 (Pentium) computer. The java interpreter java.exe, however, will run on a Windows x86 computer and can be used to interpret Program.class. In other words, java.exe opens the Program.class file and reads it byte by byte, performing different combinations of operations depending on the data read from the file. These operations are carefully selected to produce the behavior specified by the Java Virtual Machine for each byte of the file thus giving the appearance of actually executing Program.class. An alternative approach would be to translate the java bytecode Program.class file into a native Windows x86 executable just as it is about to be executed. This approach is known as Just-In-Time (JIT) compilation, and is used more commonly than interpretation on desktop and laptop computers, workstations, and servers due to its performance (i.e. speed) advantage over interpretation. In mobile devices such as cell phones and PDAs, however, interpretation is more common because just in time compilation requires more resources (memory and processor speed) than interpretation. Also, hardware implementations of the Java Virtual Machine do exist, such as the picoJava, and these require neither interpretation nor just-in-time compilation since the java bytecode program can be executed by the hardware of the computer in the same way that a pentium executes a .exe file.

The Java Development Kit (JDK) just provides the facilities necessary to write programs that will run on the Java Virtual Machine. It contains a compiler that is used to translate plain text, human readable, source code into java virtual machine readable binary java bytecodes. It does this translation in the same way that a C++ compiler translates plain text .cpp files into .exe files.

Edit:

To emphasize what I said above, the Java Virtual Machine (JVM) is an abstract concept describing the behavior of a theoretical computer. The Java Runtime Environment (JRE) is the actual software that implements this abstract virtual machine and allows binary executable files written for that virtual machine to be run on any physical machine for which the Java Runtime Environment is installed on. This is what gives Java its powerful cross platform capability, which is often described as "write once, run anywhere".

Message was edited by:

@modi

@modia at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 3

> > If your fingers are broken and you can't google or

> > wiki yourself, here ya go, on a spoon, ready to

> eat:

> >

> > http://en.wikipedia.org/wiki/JRE

> >

> > http://en.wikipedia.org/wiki/Jvm

> >

> > http://en.wikipedia.org/wiki/JDK

>

> Oh come on, that wasn't nice. Not everybody is able

> to answer their own questions.

They should at least try. When it comes to terminology, if they can find this site, they should be able to find google, wikipedia, etc. It's reasonable to expect them to try there first, and then, if they still have questions, post here, indicating what they looked at and how it fell short, what they're still confused about, etc.

> But anyway, to answer your question deepakorsun, the

> JVM is the Java Virtual Machine

> and it is the abstract architecture of a machine

> (computer). It is called virtual because it is not an

> actual machine like an Intel based PC, but is run

> virtually (i.e. simulated or emulated) by software on

> a physical computer such as an Intel based PC.

I believe physical JVM hardware has also been manufactured. I wonder what we'd call that? A JPM (Java Pysical Machine)?

> .class files are executed by software (in fact, the

> software that executes the .class files is called the

> JRE and is short for the Java

> Runtime Environment). The Java Runtime

> Environment is a native program (i.e. it is run by

> hardware) which provides the ability to execute java

> bytecodes (.class files)

That's the JVM.

The JRE is the JVM plus native libraries plus core API Java classes.

> The Java Development Kit (JDK) just provides the

> facilities necessary to write programs that will run

> on the Java Virtual Machine. It contains a compiler

It also contains tools such as jar and javap, the API docs for the core API classes, the source code for the API classes, probably a few other things, and generally the JRE (though I'm not sure if that's officially a required part of the JDK).

jverda at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 4

> Oh come on, that wasn't nice. Not everybody is able

> to answer their own questions.

WTF are you talking about?!? Why waste the time to type something out when they can click on a link and find 1000 times more information than you can fit into one post? Either way - they're STILL going to have to read the information themselves...

Ridiculous.

Navy_Codera at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 5

> Oh come on, that wasn't nice. Not everybody is able

> to answer their own questions. Java terminology can

> be confusing and difficult to understand in part

> because of all the acronyms used and all the name

> changes undergone by the various development kits and

> platforms.

Point taken. You have much more patience than I, but with lots of intensive therapy and proper adjustment of my medications, I may get better.

petes1234a at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 6

> They should at least try. When it comes to

> terminology, if they can find this site, they should

> be able to find google, wikipedia, etc. It's

> reasonable to expect them to try there first, and

> then, if they still have questions, post here,

> indicating what they looked at and how it fell short,

> what they're still confused about, etc.

Perhaps this is a valid point.

> I believe physical JVM hardware has also been

> manufactured. I wonder what we'd call that? A JPM

> (Java Pysical Machine)?

No. It is simply a hardware implementation of the abstract Java Virtual Machine.

> > .class files are executed by software (in fact,

> the

> > software that executes the .class files is called

> the

> > JRE and is short for the Java

> > Runtime Environment). The Java

> Runtime

> > Environment is a native program (i.e. it is run by

> > hardware) which provides the ability to execute

> java

> > bytecodes (.class files)

>

> That's the JVM.

No it's not. The JVM is an abstract architecture.

> The JRE is the JVM plus native libraries plus core

> API Java classes.

The JRE is an implementation of the JVM along with some additional facilities. The JVM may be used to describe concrete implementations in industry vernacular, but this is not a technically accurate usage of the term per the specification and is therefore incorrect.

From the preface to the Java Virtual Machine Specification, Second Edition, viewable at http://java.sun.com/docs/books/jvms/second_edition/html/Preface.doc.html:

"The Java virtual machine is an abstract machine."

From Wikipedia (http://en.wikipedia.org/wiki/JVM):

"A Java Virtual Machine (JVM) is a set of computer software programs and data structures which implements a specific virtual machine model."

Perhaps this misconception is the source of the confusion. This is one reason why I answered deepakorsun rather than refer him to somewhere else: anywhere that would be reliable and/or completely accurate would be too dense to readily understand, and anywhere understood easily enough might not be completely accurate.

>

> > The Java Development Kit (JDK) just provides the

> > facilities necessary to write programs that will

> run

> > on the Java Virtual Machine. It contains a

> compiler

>

> It also contains tools such as jar and javap, the API

> docs for the core API classes, the source code for

> the API classes, probably a few other things, and

> generally the JRE (though I'm not sure if that's

> officially a required part of the JDK).

I never said it didn't contain jar, javap, javac, java, jdb, jconsole, or any of the other programs or resources shipped with jdk. I simply stated affirmatively something it did contain. As I implied before, technical comprehensiveness is exactly what makes resources such as the JVM specification almost unusable for answering questions like this. That is why I omitted such details in my description. And since we're being all technical here, the API documentation does not ship with the Java Development Kit (at least not as of JDK 5.0), it is a separate download. It is the core API source files that ship in a .zip file with the JDK.

Don't get me wrong, I do understand that you have probably seen a lot more people come and go from these forums than I may ever understand and that you have helped more people than you can remember, and I don't mean to disrespect that. I understand that dealing with so many people over such a long period of time and hearing the same questions over and over again can probably start to wear on your patience, but I don't think the right approach is to treat anyone that tries to help them with utter contempt and sarcasm. That's not constructive or useful to anyone. I understand why you would be upset if somebody was purposely trying to be lazy, I probably would be too, but you have no real way of determining whether or not they are being lazy or just don't know something and don't know how to figure it out for themselves so they are asking a question. And if they are honestly just asking a question in good faith and looking up the answer on Wikipedia just did not occur to them (or they couldn't understand what it said), yet they somehow ended up on this site, they have done nothing wrong and there is no reason to get angry at them.

> > Oh come on, that wasn't nice. Not everybody is

> able

> > to answer their own questions.

>

> WTF are you talking about?!? Why waste the time to

> type something out when they can click on a link and

> find 1000 times more information than you can fit

> into one post? Either way - they're

> STILL going to have to read the

> information themselves...

>

> Ridiculous.

So I suppose you've either read the Java Virtual Machine Specification, the Java Language Specification, and the Java Native Interface Specification in their entireties, or absolutely nothing about programming in Java. This is because, by your reasoning, these three books contain 1000 times more than anyone can fit on a tutorial, Wikipedia entry, mailing list, forum, blog, or anything else.

Criticizing somebody who isn't doing something the exact way you think it should be done is often quite idiotic and non-constructive. I believe this is this case here. Please post something more useful, meaningful, and/or polite next time. And just for future reference, yelling at a beginner does not help them learn faster or better. It just makes them hate you.

> > Oh come on, that wasn't nice. Not everybody is

> able

> > to answer their own questions. Java terminology

> can

> > be confusing and difficult to understand in part

> > because of all the acronyms used and all the name

> > changes undergone by the various development kits

> and

> > platforms.

>

> Point taken. You have much more patience than

> I, but with lots of intensive therapy and proper

> adjustment of my medications, I may get better.

Thank you for this post. A display of wisdom and patience. You single handedly caused me to reconsider participating in a flame war.

@modia at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 7
> Thank you for this post. A display of wisdom and> patience. You single handedly caused me to reconsider> participating in a flame war.LOL. touch?
petes1234a at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 8

> > They should at least try. When it comes to

> > terminology, if they can find this site, they

> should

> > be able to find google, wikipedia, etc. It's

> > reasonable to expect them to try there first, and

> > then, if they still have questions, post here,

> > indicating what they looked at and how it fell

> short,

> > what they're still confused about, etc.

>

> Perhaps this is a valid point.

There's no perhaps about it.

> > > .class files are executed by software (in fact,

> > the

> > > software that executes the .class files is

> called

> > the

> > > JRE and is short for the Java

> > > Runtime Environment). The Java

> > Runtime

> > > Environment is a native program (i.e. it is run

> by

> > > hardware) which provides the ability to execute

> > java

> > > bytecodes (.class files)

> >

> > That's the JVM.

>

> No it's not. The JVM is an abstract architecture.

Point taken. However, in the vernacular, "JVM" is often used to refer to java.exe or the platform-appropriate equivalent.

It seems like you're saying that the executable is the JRE, and I was merely making the point that there's more to it than that.

> since we're being all technical here, the API

> documentation does not ship with the Java Development

> Kit

You're right. Don't know what I was thinking.

> Don't get me wrong, I do understand that you have

> probably seen a lot more people come and go from

> these forums than I may ever understand and that you

> have helped more people than you can remember, and I

> don't mean to disrespect that.

No problem. We give you permission to disagree with Our Opinion. ;-)

> I understand that

> dealing with so many people over such a long period

> of time and hearing the same questions over and over

> again can probably start to wear on your patience,

> but I don't think the right approach is to treat

> anyone that tries to help them with utter contempt

> and sarcasm.

Was someone treated with utter contempt? Sarcasm's generally cool, IMAO.

jverda at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 9

First of all I thank you all for your valuable responses.

I was told that the sun's java forum is the place where you get most precise answers. Although, if You din't liked the way I posted my query, I ll try to do better in future. And Well If I have hurt anyone, I am really sorry for that.

Once again Last but not the least Thanks a lot for the reply to my query...:))

null

deepakorsuna at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 10

> And Well If I have hurt

> anyone, I am really sorry for that.

> nce again Last but not the least Thanks a lot for the

> reply to my query...:))

No coders were hurt in the attempt to answer this question. I can guarantee you that. My main reason for sarcasm was

[soapbox]

1) the question was way too general, akin to "describe the universe; please give me three examples", and

2) you didn't demonstrate that you had put any effort into this before asking.

Next time, ask away, but demonstrate that you've put effort and thought into the problem before asking others to do the same.

[/soapbox]

Now where are my Dukes?

Message was edited by:

petes1234

petes1234a at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 11
> Now where are my Dukes?Yes where are they now that you've excelled in sarcasm.
judjeia at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 12
> > Now where are my Dukes?> > Yes where are they now that you've excelled in> sarcasm.Oh yeh, he was really sarcastic, wasn't he!?
georgemca at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 13
> > > Now where are my Dukes?> > > > Yes where are they now that you've excelled in> > sarcasm.> > Oh yeh, he was really sarcastic, wasn't he!?Glad you noticed, but you were always a scavenger weren't
judjeia at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 14

Woohh baby..!! This post was Hot!! everyone has a good point.Having said that,it was not nice to reject the question the way some did,or to personally attack the person(fingers are broken or what not),just nicely answer it or nicely point the person to google,it wont hurt anything or anybody.

It takes a lot for some of us to ask questions,so if one has the courage to do so,take that into consideration.

I do understand, putting in the effort but at times,someone's explanation,or direct explanation,or simple explanation is more helpful than reading tons of information. At times,you need certain information right then and there.Still,try to be nice, there is no need to get personal. Some of us come here to get help,learn,evolve,get better,and help others not to hurt anyone,or anyone's feelings.

Im glad that no developers were hurt in the process though :-).

No Dukes should be awarded for now...except to @modi until everyone cools off.

exl5a at 2007-7-12 20:37:50 > top of Java-index,Java Essentials,New To Java...
# 15

> No Dukes should be awarded for now...except to @modi

> until everyone cools off.

This is not your thread so you're not entiteled to give away any dukes.

Still I dislike your style. Dukes won't buy you anything around here so just drop it. Dukes are dead. They died when bbritta, mercy on his soul, gave away all his millions.

judjeia at 2007-7-21 22:44:42 > top of Java-index,Java Essentials,New To Java...
# 16

> > No Dukes should be awarded for now...except to

> @modi

> > until everyone cools off.

>

> This is not your thread so you're not entiteled to

> give away any dukes.

> Im not giving away any dukes,you dont get any by the way..says Me.

> Still I dislike your style. Dukes won't buy you

> anything around here so just drop it. Dukes are dead.

Dukes still can come back alive..so watch out.Even dead Dukes dont like your styles.

exl5a at 2007-7-21 22:44:42 > top of Java-index,Java Essentials,New To Java...
# 17
Dukes make my pixels all shiny.Take that however you want.
Djaunla at 2007-7-21 22:44:42 > top of Java-index,Java Essentials,New To Java...
# 18

> Woohh baby..!! This post was Hot!! everyone has a

> good point.Having said that,it was not nice to reject

> the question the way some did,or to personally attack

> the person(fingers are broken or what not),just

> nicely answer it or nicely point the person to

> google,it wont hurt anything or anybody.

>

> It takes a lot for some of us to ask questions,so if

> one has the courage to do so,take that into

> consideration.

So I have to ask how is asking a question for google to answer different from ansking a question for another person to answer ? (Excluding the very obvious that google doesn't care if it answers the same question thousands of times over).

Aknibbsa at 2007-7-21 22:44:42 > top of Java-index,Java Essentials,New To Java...
# 19

> So I have to ask how is asking a question for google

> to answer different from ansking a question for

> another person to answer ? (Excluding the very

> obvious that google doesn't care if it answers the

> same question thousands of times over).

I think the basic point from this thread is that the differences between JVM, JRE, and JDK may be very difficult to understand for a newbie. I've been doing Java for awhile now and I still find it difficult to understand parts (ok most) of the JVM specification. The reason such an in-depth reply was given is because it was less detailed and more general (therefore easier to understand) than an answer would be that was given by Google or Wikipedia.

Djaunla at 2007-7-21 22:44:42 > top of Java-index,Java Essentials,New To Java...
# 20

There may be a difference,there may not be a difference.You can answer it,summarize it quickly for someone,while on google its a bunch of wordy documents that the person has to read.

But,thats not the point here,you can nicely say to someone..Hey why dont you google that particular subject and see what you come up with?. instead of...your fingers are cut,here it is on a silver spoon,etc..No.Thats not necessary I think.

exl5a at 2007-7-21 22:44:42 > top of Java-index,Java Essentials,New To Java...
# 21

> So I have to ask how is asking a question for google

> to answer different from ansking a question for

> another person to answer ? (Excluding the very

> obvious that google doesn't care if it answers the

> same question thousands of times over).

Are you paralyzed? Why don't you just Google for the answer to this question? Do you want it on a silver spoon?

;-)

Djaunla at 2007-7-21 22:44:42 > top of Java-index,Java Essentials,New To Java...
# 22
Nice :-). Yeah tell him Djaunl.
exl5a at 2007-7-21 22:44:42 > top of Java-index,Java Essentials,New To Java...
# 23
> Dukes still can come back alive..so watch out.Even> dead Dukes dont like your styles.Well you come back like a vampire right. When you have them pinned down you bite them again with your dukes.
judjeia at 2007-7-21 22:44:42 > top of Java-index,Java Essentials,New To Java...
# 24
> Well you come back like a vampire right. When you> have them pinned down you bite them again with your> dukes.Yeah, just like you came back like a vampire from your C# project. You probably did pin them down,then they struck back..and there you are.
exl5a at 2007-7-21 22:44:42 > top of Java-index,Java Essentials,New To Java...
# 25

> > So I have to ask how is asking a question for

> google

> > to answer different from ansking a question for

> > another person to answer ? (Excluding the very

> > obvious that google doesn't care if it answers the

> > same question thousands of times over).

>

> Are you paralyzed? Why don't you just Google for the

> answer to this question? Do you want it on a silver

> spoon?

Wouldn't you feel like such a smuck if I actually was paralyzed ? (Lucky for you no I am able bodied ;-P)But my point was that the jvm versus sdk comes up a lot,and it will annoy those regulars who you would rather see stick around. I am a little busy to look around but I am fairly certain one would find a concise explanation of the sdk and the jre on wikipedia. I will have a look this weekend. I haven't got to the point where I can read the specs and understand them, but I will keep on working on them, and if I have a particular question I will ask about it, it then shows that I have at least put a bit of effort into it, but that's just me. That attitude seems to be more of a dying thing these days.

Aknibbsa at 2007-7-21 22:44:42 > top of Java-index,Java Essentials,New To Java...
# 26

> I am fairly certain one would find a

> concise explanation of the sdk and the jre on

> wikipedia.

You are right, the wikipedia explanations were quite nice, simple, relatively short, and even for me, understandable. I have to admit that I benefited by having this thread force me to take a look over those pages.

petes1234a at 2007-7-21 22:44:42 > top of Java-index,Java Essentials,New To Java...