Can anyone tell me what is
TVM in Java? 😁
Ok, coming to the question, I will try to clear the entire doubt that most of the people have regarding three different terms JDK, JVM and JRE.
Let me first talk about only JDK and JRE, the very first thing one need to be cleared while installing java in the system.
JRE [Java RunTime Environment] provides an environment for running[Note : not for compiling also] your Java programs. It contains JVM, class libraries and other supporting files but not compiler and debugging tools. The compiler and debugging tools are packed in JDK[Java Development toolkit] . If you have Java installed in your system check the
jdk folder. Inside it there will be a
jre folder also. So even if you have not installed
jre in your system, you will find you are able to both compile and run Java programs but if you have installed only
jre, it will have not have
javac.exe in its bin folder. It will have only java.exe. For the sake of lazy people like you, I will show you with images.
1. Both jdk and jre folders in my system
2. Check inside jre folder, Go to its bin folder, you will see only "java.exe". No "javac.exe" is there.
3. Now do the same as above with "jdk" folder. You will find both "java/exe" and "javac.exe" will be there.
2. And if you see inside jdk folder, you will see a jre folder also.
So this was the role of JRE AND JDK. If you want to only run the Java programs, you can do so only installing jre[As it is done in most of the client machines] but if your are developing Java programs, you definitely need to install jdk.
Now let's come to the role of JVM which has no comparison to JRE. JRE - provides you an environment for running Java programs. Running Java programs means converting Java .class files[also called as bytecodes] into executable files.
JVM[Java Virtual Machine] concept is introduced for making platform independent programs . It is an engine that interprets the bytecodes [.class files] and convert them into machine code based on the underlying hardware and OS of the machine. JVM acts as an interface to the machine and JRE is its implementaion. Using JRE, you make the programs runnable but it is JVM that decides how to make that program runnable 'everywhere'. JVM is machine dependent but it is called as "virtual" as it is only an interface to the machine irrespective of machine's architecture.
Hope you got the point now. Feel free to add more or correct me.