Let’s understand all the three elements with some diagram first.
JDK = JRE + JVM
• As name depicts it’s a tool for development, but for development of what?
• It is a software development kit to develop applications in Java.
• So it’s a kind of complete package, if you have this you can develop your own java application nothing else is required.
• Now as it is a complete tool it must be consist of several elements or we can say sub tools.
• Now JDK composed of several sub tool namely:
JRE + Compiler + Debuggers + JavaDocs
JRE - Java Run time Environment
• Now as you see JRE is a sub tool of JDK
• As name depicts it provides run time environment for your java application to run
• As you have JDK you will start developing your java application i.e.
• You will write your java program i.e. .java file right?
• As soon as you are done with writing your .java file i.e. Java Source Code
• Next you will compile that code i.e. will convert it to .class file
• .class file is also called as your Byte Code
• Now as you are done with your compilation process you need to run your application
• Here comes the role of JRE.
• JRE will provide you a run time environment to run your application.
• In order to provide this environment JRE make use of its sub tool
• And JVM is a sub tool of JRE.
• JRE is responsible for running an application, so it can be downloaded separately
• In case you do not need to develop any application, rather you are interested in just running the application yo do not need to download whole JDK, JRE will be enough in this case.
• The purpose of JVM is to translate byte code into native machine code.
That’s why JVM is Machine Specific, let’s understand how?
• We all know that Java is a platform-independent language.
• It's because when you write Java code, it's ultimately written for JVM but not your physical
machine.
• JVM translates byte code into native machine code, In order to generate machine specific code
JVM needs to be machine specific.
• That’s why you have different JVM for Windows, Linux or Solaris but one JAR can run on all
this operating system.
• So in order to make java a platform independent our JVM is a platform dependent.
• Every type of Machine (Windows / Linux / Mac) has a specific JVM.
• In this way the coder doesn't need to bother with generating byte code. JVM takes care of
portability
• We can say Java is Portable but JVM is Machine Specific.
Next we can ask what are machine codes?
• Machine code are set of instructions that a computer's CPU executes directly)
• After JVM converts byte code to machine code CPU executes those instructions and gives the
output.
No comments:
Post a Comment