Java Virtual Machine (JVM)
Java virtual machine is an abstract machine. Java virtual machine is a software and it is a specification that provides runtime environment in which java bytecode can be executed. Java virtual machine is platform dependent. JVM, JRE and JDK platform dependent because configuration of each operating system differ. But java is pure independent programming language.
Java Virtual Machine perform some main task, these are
- Loads code
- Verifies code
- Executes code
- Provide runtime environment
Java Runtime Environment (JRE)
Java runtime environment , It is used to provide runtime environment in java. JRE is an implementation of jvm which actually executes java programs. It include the jvm , core libraries and other additional components to run application and applets written in java.
JRE = jvm + core libraries(e.g rt.jar files etc.) + other files
Java Development Kit (JDK)
Java development kit is used to develop and execute the java programs. jdk is bundle of software components that is used to develop java based application. JDK contains everything that will be required to develop and run java application. it contains JRE and other development tools e.g javac, java, etc.
JDK = JRE + development tools(e.g javac , java, etc)
Difference between Java and C++
java
- Java is platform-independent
- Java is mainly used for application programming. It is widely used in desktop application, mobile application, enterprise application.
- Java does not support pointers, templates, union, operator overloading, structures.
- Java does not support multiple inheritance through a class. It can be achieved by interface in java.
- Java support automatic garbage collection. Java does not support destructors.
- Java does not support goto statement.
- Java does not support conditional compilation inclusion.
- Java has built in support for threads. There is a thread class in java that you inherit to create new thread and override the run() method.
- Java uses compiler and interpreter both
- Java support call by value only. Java does not support call by reference.
- Java has built-in support for documentation comment e.g /**-----*/
- Java has no virtual keyword. We can override all non-static method by default.
- Java does not supports default arguments. In java there is no scope resolution operator (::).
C++
- C++ is platform-dependent
- C++ is mainly used for system programming
- C++ supports pointers, templates, union, structures, operator overloading.
- C++ support multiple inheritance.
- C++ support destructors, Which is automatically invoked when object is destroyed
- C++ supports goto statement.
- C++ supports conditional compilation and inclusion.
- C++ has no built-in supports for thread. C++ relies on non-standard third parties libraries for thread support.
- C++ uses compiler only.
- C++ support call by value and call by reference both.
- C++ has not built-in support for documentation comment.
- C++ supports virtual keywords so that we can decide whether or not override methods.
- C++ supports default arguments. C++ has scope resolution operator(::), Which is used to define a method outside a class and to access a global variables within from the scope where a local variable also exists with the same name.