#What is the difference between JRE, JVM and JDK.

1 messages · Page 1 of 1 (latest)

old heart
#

Hello guys, It's been a long time that I'm learning java now but I never asked myself the differences between the JRE, the JVM and the JDK. From what I've read, JRE is the run time environment, which means a java program will run on our pc if we have it installed. But since we don't have the JVM yet, it means it's platform dependent ?

Now the JVM, is what makes java platform independent by converting .java file into .class file which has the bytecode in it which will later be interpreted/translated into machine instructions.

For the JDK, from what I read, the JDK include tools like debuggers but it's still vague.

Can someone add on to this and correct any mistake if any pls

livid sphinxBOT
#

<@&987246399047479336> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
Hello guys, It's been a long time that I'm learning java now but I never asked myself the differences between the JRE, the JVM and the JDK. From what I've read, JRE is the run time environment, which means a java program will run on our pc if we have it in

understand, the JRE (Java Runtime Environment) is the package that allows a computer to run Java programs. It includes the JVM (Java Virtual Machine), which is responsible for executing Java code.

The JDK (Java Development Kit), on the other hand, is a full-featured software development kit that includes everything needed to develop Java applications. This includes the JRE as well as tools like compilers and debuggers for writing and testing code.

In summary, the JRE is needed to run Java programs, while the JDK is needed to develop them. The JVM is part of the JRE and is responsible for executing Java code. It's important to have both the JRE and JDK installed on your computer if you want to both run and develop Java applications.

small kindle
#

Now the JVM, is what makes java platform independent by converting .java file into .class file which has the bytecode in it which will later be interpreted/translated into machine instructions.
that isnt true, the jvm doesnt compile from .java to .class
instead it loads and runs bytecode (.class) and converts it to machine specific code

old heart
#

so we can only kind of "write bytecode" ?

small kindle
#

the jdk includes a compiler known as javac

crude crest
#

JRE is the runtime environment, contains the JVM as well as other things

#

JVM is what executes our Java program (hence part of the runtime environment). JRE also contains the JCL and such, all the possible GCs available, etc..

small kindle
crude crest
#

as well as GC implementations, verifiers, etc..

#

contains everything needed to run a Java program

small kindle
#

the jdk contains jre + development tools like a compiler and much more

crude crest
#

JDK even comes with a profiler iirc, VisualVM

#

comes with the JAR program, key signing, etc.. tons of tools

small kindle
#

jre is for users to run java applications
jdk is for developers to create java applications

#

though I think nowadays most just get a jdk

crude crest
#

users don't need to install JREs anymore, because a runtime typically comes bundled with the Java app

#

so yeah, very rarely will you have to worry about JRE as a separate thing

small kindle
#

though it goes into a lot of detail

old heart
#

hmm the thing is

#

the JRE already includes a compiler?

crude crest
#

nope

small kindle
#

it doesnt

old heart
#

but what about javac

small kindle
#

the jdk includes javac

crude crest
small kindle
#

the user doesnt need to compile .java

#

he will get some .jar (which contains compiled .class files) and just runs it with the jre

old heart
#

yeah the JDK does it for the user

crude crest
#

the dev does it for the user. the JDK provides the dev with the tools to do so

old heart
#

with only the JRE, without JVM or JDK, a program can't run ?

crude crest
#

JRE has the JVM

old heart
#

ah

#

it's not in order like first we have JRE, then JVM then JDK

old heart
#

ahhh

#

makes more sense

crude crest
#

the JRE consists of the JVM, some verifiers, and the class libraries

old heart
small kindle
small kindle
crude crest
#

Even though a compiler for the Java programming language must only produce class files that satisfy all the static and structural constraints in the previous sections, the Java Virtual Machine has no guarantee that any file it is asked to load was generated by that compiler or is properly formed

#

from the JVM spec

#

jvm does perform verification at linking time

small kindle
#

ok yeah

crude crest
#

but there's verification before it even hits the VM

#

as a dev, the only thing you need to worry about is the JDK

#

it contains a JRE, and the JRE contains the JVM

#

it's everything a user would need, + the tooling to help with development

old heart
#

yep I see

#

just to summarise:

JVM forms part of the JRE; the JRE includes everything needed to make the program work. That is, it include the JVM and libraries..

The JDK wraps the JRE which just allows dev to run their app ?

crude crest
#

JDK is basically the JRE, but with some extra tools

old heart
#

yeah, it's more about creating that running app ?

crude crest
#

yup

#

devs can run their apps without a JDK

#

but need the JDK to develop the apps

old heart
#

yep I see

#

Thanks !!

crude crest
#

hence why its the Java Development Kit

small kindle
#

you can say the main tool of the jdk is the compiler

#

which makes clear that it is used to create apps

old heart
#

ok, noted, ty !!

sharp mango
#

JVM is a piece of software that executes Java bytecode
JRE is a distribution of Java that is sufficient to run Java applications, includes JVM and some other stuff (like the standard library)
JDK is an all-in-one dsitribution of Java that has everything that JRE has, but also compiler, debugger and so on