4. Difference between JVM, JRE and JDK


Java Virtual Machine: Previous                                                                  Next: Java Data Types                     

Difference between JVM, JRE and JDK

JVM (Java Virtual Machine):

JVM is a virtual machine or a program that provides run-time environment in which java byte code can be executed. JVMs are available for many hardware and software platforms. The use of the same byte code for all JVMs on all platforms make java platform independent.

Main task of JVM:

  • 1. Search and locate the required files.
  • 2. Convert byte code into executable code.
  • 3. Allocate the memory into ram
  • 4. Execute the code.
  • 5. Delete the executable code.

JRE (Java RunTime Environment):  

        JVM + java runtime libraries + java package classes (e.g. util, lang etc). JRE provides class libraries and other supporting files with JVM. It not provide any development tool like compiler, debugger etc.


JDK (Java Development Kit):

       JRE+ development tool (compiler, debugger etc.). JDK contains tools to develop the application and JRE to execute the application.

Java Coding Guidelines

1. Basic Naming convention standards: 

To describe variable/constant/method/class/interface etc use full descriptor. E.g.: rollNumber, firstName, lastName, getTotalMarks().

2. Naming variable:

Use first word in small letters and all remaining words will be capitalized. E.g. – rollNumber, firstName.

3. Naming Constants:

Use all letters in upper case. E.g. – MAX_MARKS.

4. Naming methods:

a). Naming member methods : 
Use first word in small letters and all remaining words will be capitalized. E.g. – getTotalMarks().
b). Naming accessor methods:
for getters – use get as prefix to property (for non Boolean properties). e.g. – getRollNumber().
for setters – use set as prefix to property. e.g. – setRollNumber().
use is as prefix to property(for Boolean properties). e.g. – isNewStudent().

5. Naming class/interface:

Use capitalized words for class/interface name. E.g.- HelloWorld.

6. Comment: 

For clarity of the code add comments.


Java Virtual Machine: Previous                              &nbs.p;                                   Next: Java Data Types