Presentation is loading. Please wait.

Presentation is loading. Please wait.

Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.

Similar presentations

Presentation on theme: "Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment."— Presentation transcript:

1 Session-02

2 Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment Setup How to set path in Java What is Life Cycle of Java?

3 What is Class Loader ? Classloader is a subsystem of JVM that is used to load class files at runtime. A class loader is an object that is responsible for loading classes. The ClassLoader is an abstract class. Given the binary name of a class A typical strategy is to transform the name into a file name and then read a "class file" of that name from a file system.

4 Continue... ClassLoader in Java works on three principle: delegation, visibility and uniqueness. Delegation Delegation principle forward request of class loading to parent class loader and only loads the class, if parent is not able to find or load class. Visibility Visibility principle allows child class loader to see all the classes loaded by parent ClassLoader, but parent class loader can not see classes loaded by child. Uniqueness Uniqueness principle allows to load a class exactly once, which is basically achieved by delegation and ensures that child ClassLoader doesn't reload the class already loaded by parent.

5 Example

6 How to load class explicitly in Java? Java provides API to explicitly load a class by Class.forName(class name) and Class.forName(class name, initialized, classloader). JDBC code which is used to load JDBC drives we have seen in Java program to Connect Oracle database.

7 What is Byte Code Verifier? The JVM verifies all bytecode before it is executed. This verification consists primarily of three types of checks: 1.Branches are always to valid locations 2.Data is always initialized and references are always type-safe 3.Access to private or package private data and methods is rigidly controlled The first two of these checks take place primarily during the verification step that occurs when a class is loaded and made eligible for use. The third is primarily performed dynamically, when data items or methods of a class are first accessed by another class.

8 Bytecode interpreter and just-in-time compiler For each hardware architecture a different Java bytecode interpreter is needed. When a computer has a Java bytecode interpreter, it can run any Java bytecode program, and the same program can be run on any computer that has such an interpreter. A just-in-time compiler may translate Java bytecode into native machine language while executing the program. The translated parts of the program can then be executed much more quickly than they could be interpreted. This technique gets applied to those parts of a program frequently executed. This way a just-in-time compiler can significantly speed up the overall execution time. Java bytecode is intended to be platform-independent and secure.

9 JIT A Just-In-Time (JIT) compiler is a feature of the run-time interpreter, that instead of interpreting bytecode every time a method is invoked, will compile the bytecode into the machine code instructions of the running machine, and then invoke this object code instead. Ideally the efficiency of running object code will overcome the inefficiency of recompiling the program every time it runs.

10 Continue...

11 JAVA API By default JAR File loaded by Class Loader By default Java Package used by all classes An API (Application Programming Interface) is a collection of packages, a package is the collection of classes, interfaces and sub-packages. A sub-package is a collection of classes interfaces and sub sub packages etc.

12 Features of Java There is given many features of java.

13 1)Simple According to Sun, Java language is simple because: syntax is based on C++ (so easier for programmers to learn it after C++). Removed many confusing and/or rarely-used features e.g., explicit pointers, operator overloading etc. No need to remove unreferenced objects because there is Automatic Garbage Collection in java.

14 Comparison Table of Features(C,C++& Java)

15 2)Object-oriented Object-oriented means we organize our software as a combination of different types of objects that incorporates both data and behaviour. Object Class Inheritance Polymorphism Abstraction Encapsulation

16 3) Platform Independent A platform is the hardware or software environment in which a program runs. There are two types of platforms software-based and hardware-based. Java provides software-based platform.

17 4) Secured No explicit pointer, Programs run inside virtual machine sandbox. Classloader, Bytecode Verifier & Security Manager.

18 5) Robust Robust simply means strong. Java uses strong memory management. There is automatic garbage collection in java. There is exception handling and type checking mechanism in java. All these points makes java robust.

19 6) Architecture-neutral Architecture represents processor. A Language or Technology is said to be Architectural neutral which can run on any available processors in the real world without considering there architecture and vendor (providers) irrespective to its development and compilation. The languages like C, CPP are treated as architectural dependent.

20 7) Portable A portable language is one which can run on all operating systems and run on all processors without considering their vendors and architectures. JAVA is a portable language.

21 8)High-performance

22 9)Multithreaded A flow of control is known as thread. When any Language execute multiple thread at a time that language is known as multithreaded Language.

23 10)Distributed We can create distributed applications in java. RMI and EJB are used for creating distributed applications.

24 Java is very powerful ? Java is very powerful language can be used to developed both client server architecture and distributed architecture based application.

25 Continue...

26 Java Environment Setup

27 Continue... Javac is a tool which is available in bin folder so you must set the PATH upto bin folder. In a bin folder all tools are available like javap, javah, jar, javac, java, appletviewer etc. These all tools are used for different-different purpose.

28 How to set path in Java

29 1) How to set Temporary Path of JDK in Windows

30 2) How to set Permanent Path of JDK in Windows

31 Step-2

32 Step-3

33 Step-4

34 Step-5

35 Step-6

36 Step-7

37 Step-8

38 Step-9

39 Step-10

40 What is Life Cycle of Java?

41 Example

Download ppt "Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment."

Similar presentations

Ads by Google