Java SE 8 and JDK 8 Launched.For Download:Click Here!


Social Icons


Saturday, 25 January 2014

Dissecting the First Java Program You Created

                      In the previous post Hello World - First Java Program we have learnt how to compile and run a Java Program. Now after learning that , here we will learn the meaning of the basic terms involved in the program . Also , what actually happened when we compile and run the program.So we will be dissecting our first Java Program - Hello World.
                (Note : Before reading this post , please atleast have a glance at the previous post . Click here .)

Terms involved in first java program - Hello World

Let's see what is the meaning of class, public, static, void, main, String[], System.out.println() that were used in our first Java Program.
  • class keyword is used to declare a class in java. Click here to know more about a class.
  • public keyword is an access modifier which represents visibility, it means it is visible to all.
  • static is a keyword, if we declare any method as static, it is known as static method. The main method is executed by the JVM, so it doesn't require to create object to invoke the main method. So it saves memory.
  • void is the return type of the method, it means it doesn't return any value.
  • main represents that execution of the program will be started from here.
  • String[] args is used for command line argument. This concept will be learnt in later posts.
  • System.out.println() is used to print a statement .
  • javac the tool for compiling the program file converting .java file into .class file .
What Happens at Compile Time ?

compile time

Explanation :

          At compile time when you use the "javac" command , the java file ( is 
compiled by Java Compiler(javac) without any inquiry and converts that file into bytecode 
(MyFirstJavaProgram.class) .

What Happens at Run Time ?

          After knowing how compiling of the program was done , now we will see what happened when the program started running .


Let' s see what the terms class loader , bytecode verifier , interpreter . hardware means which are used in the above diagram .
    ·    Classloader loads a java class file into java virtual machine. It is as simple as that .Class loader will be explained in further posts.
    ·     Bytecode verifier acts as a sort of gatekeeper . It ensures that code passed to the Java interpreter is in a fit state to be executed.
    ·     Interpreter translates the Java bytecode into the code that can be understood by the Operating System.
    ·     Runtime compiles verified bytecode to native machine code.
    ·     Hardware means the OS (Operating System) which executes the native machine code.

         So we have learnt the terms involved in our first program of Hello World and understood what was happening when we compile and run the program .

Keep Compiling !!

Comment With:
The Choice is Yours!

No comments:

Blogger Tips and TricksLatest Tips And TricksBlogger Tricks

Follow JavaCompile by Email

Related Posts Plugin for WordPress, Blogger...

Total Pageviews


Blogger Widgets