An Overview of Java
JVM (Java Virtual Machine)
JVM is a virtual machine and it stays on top of the operating system. It provides the runtime environment where Java byte-code can be run. JVM is different for every operating system so it is platform dependent.
What does JVM do?
- Locates a file and loads the code.
- Verifies the code.
- Converts byte-code into machine code (executed code).
- Allocates the memory into RAM.
- Executes the code.
JIT stands for just in time compiler. It converts the byte code of one operating system to current operating system executable code. This instruction is given by JVM of the current operating system. This byte-code converts into native platform code.
Java Runtime Environment (JRE)
JRE provides the runtime environment. It contains the JVM and many other library files. It is the part of Java development kit (JDK) and it cannot be downloaded separately. It physically exits.
Java Development Kit (JDK)
JDK is the software development environment. It is used for developing java program and applet. It includes the JRE (Java runtime environment), javac (Java compiler), jar, javap, etc.
Procedure to develop Java program
Fig: Procedure to develop Java Program
Example: First Java program
public static void main(String args)
C:\> javac FirstProgram.java
C:\> java FirstProgram
- class is a keyword in Java and everything is written under the class.
- public is an access modifier which provides the accessibility of main method to all.
- static is a keyword and main methods are always declared as static. There is no need to create an object to invoke the static method.
- void shows the main methods that do not return any kind of value.
- String args is used for command line argument.
- System.out.println() is used for printing the statement.