Wednesday, September 9, 2015

Internal Details of Hello Java Program


In the previous page, we have learned about the first program, how to compile and how to run the
first java program. Here, we are going to learn, what happens while compiling and running the java
program.Moreover, we will see some question based on the first program.


What happens at compile time?


At compile time, java file is compiled by Java Compiler (It does not interact with OS)
and converts the java code into bytecode.

----------------------------------------------------------------------------------------------
class Simple
{                                                       
     public static void main(String args[])
             {
                System.out.println("Hello Java");   ----->Compiler            --->Byte Code
             }                                                               javac                   i.e Simple.class
}
----------------------------------------------------------------------------------------------

 What happens at runtime?

Simple.class
-->
class Loader
-->
Byte Code Verifier
-->
Interpreter
-->
Runtime
-->
Hardware

Classloader: is the subsystem of JVM that is used to load class files.

Bytecode Verifier: checks the code fragments for illegal code that can violate access right to objects.

Interpreter: read bytecode stream then execute the instructions.

No comments:

Post a Comment