Lecture 3


Published on

Notes on core java

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Lecture 3

  1. 1. Core Java Debasish Pratihari Hello world Program File Name : Lakshya.java class Lakshya { public static void main(String args[]) { System.out.println(“Welcome to Lakshya..”); } } To compile: javac Lakshya.java To Run : java Lakshya Lakshya.java Compilation javac Lakshya.class Lecture/core/intro3/03 Source code javac Bytecode Page #1 feel the Technology…
  2. 2. Core Java Debasish Pratihari Bytecode:  An architecture neutral intermediate format designed to transport code efficiently to multiple hardware and software.  Bytecode is the intermediate representation of Java programs  A bytecode program is normally executed by parsing the instructions one at a time. To see the Bytecode: Javap –c Lakshya .class file Compiled from "Lakshya.java" name class Lakshya extends java.lang.Object{ Lakshya(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object."<init>":()V 4: return public static void main(java.lang.String[]); Code: 0: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream; 3: ldc #3; //String Welcome to Lakshya.. 5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V 8: return } More about Bytecodes:        Bytecodes are the machine language of the JVM. There is one stream of Bytecodes for each method in the class. The Bytecodes are stored in the method area of JVM. The Bytecodes for a method are executed when that method is invoked. A Bytecode stream is a sequence of instruction for JVM. Each instruction consist of one-byte opcode followed by zero or more operands. Bytecodes can be executed by interpretation or by Just-In-Time compiler. Lecture/core/intro3/03 Page #2 feel the Technology…
  3. 3. Core Java Debasish Pratihari Java Program Execution:  A JVM starts up by loading a specified class and then invoking the main method from the specified class, providing it a single parameter of array of string.  A class must be initialize before it can be invoked.  A class must be linked before it initialized. Linking:  Verification  Well-formed  Proper Symbol Table  semantics  Preparation  Allocation of Static Storage  Create data structures required By JVM  Resolution  it is the process of checking symbolic references from a class to other classes and interface Initialize:   Class variables initalizers and static initalizers are executed. Before a class gets initializes its direct super class must be initialized. Loading of Classes and Interfaces:   Loading refers to the process of finding the binary form of a class or interface. The loading process is implemented by the class ClassLoader. Lecture/core/intro3/03 Page #3 feel the Technology…
  4. 4. Core Java Debasish Pratihari Introduction to JVM      It is a machine out of software and exits in computer memory. It is responsible to convert Java Bytecodes to native code and execute it. A runtime instance of the JVM runs one java application. Every java application need a separate JVM for their execution. The JVM instance dies after execution of a Java program. How JVM Works : 25% Inside view of JVM : Lecture/core/intro3/03 Page #4 feel the Technology…
  5. 5. Core Java Debasish Pratihari JVM Platforms: IA-64 (Itanium) IA-32 Win 32 Linux X86 OS/2 S/390 Power/PowerPC AIX OS/400 Linux PPC Linux IA-64 Win 64 Linux 390 OS/39j Just-In-Time(JIT) Compiler:  The Just-In-Time compiler is a component of Java Run-Time environment. It improves the performance of Java applications by compiling bytecodes to native machine code at run-time.  It is also referred as dynamic compilation  It can be disable by passing JVM parameter o Java –Djava.compiler=NONE Test Java Run-Time Enviro nme nt Class Lo ader Bytecode Verifier Java C lass Lib raries ByteCodes Java Interp reter Just-in-time Co mpiler Runtime S ystem Operating S ystem Hard ware Lecture/core/intro3/03 Page #5 feel the Technology…