[go: up one dir, main page]

0% found this document useful (0 votes)
107 views23 pages

Introduction To Java: Md. Samsuzzaman, Lecturer Faculty of Cse, Pstu

1. The document introduces Java, describing its origins at Sun Microsystems and initial motivation as a platform independent language. 2. It explains key aspects of Java including being object oriented, portable, robust, secure, distributed, and high performance. 3. The document provides an overview of how Java works in two stages with bytecode that is executed by the Java Virtual Machine (JVM) on any platform.

Uploaded by

Gyanil Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views23 pages

Introduction To Java: Md. Samsuzzaman, Lecturer Faculty of Cse, Pstu

1. The document introduces Java, describing its origins at Sun Microsystems and initial motivation as a platform independent language. 2. It explains key aspects of Java including being object oriented, portable, robust, secure, distributed, and high performance. 3. The document provides an overview of how Java works in two stages with bytecode that is executed by the Java Virtual Machine (JVM) on any platform.

Uploaded by

Gyanil Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

Introduction to Java

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU

1.

The complete reference of java 2 (J2SE 6 Edition)


Author : Herbert Schieldt 2. Programming in Java2 Author : E. Balagurusamy Web Source: http://java.sun.com/docs/books/tutorial/ http://java.sun.com/javase/6/docs

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU

Java is a general purpose object oriented programming language. Developed by Sun Microsystems. (James Gostling) Initially called Oak but was renamed as Java in 1995. Initial motivation is to develop a platform independent language to create software to be embedded in various consumer electronics devices. Become the language of internet. (portability and security).

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU

1.
2. 3. 4. 5. 6. 7. 8. 9.

Simple, Small and Familiar Compiled and Interpreted Object Oriented Platform Independent and portable Robust and Secure Distributed / Network Oriented Multithreaded and Interactive High Performance Dynamic

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

Similar to C/C++ in syntax But eliminates several complexities of No operator overloading No direct pointer manipulation or pointer arithmetic No multiple inheritance No malloc() and free() handles memory automatically

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

Java works in two stage


Java compiler translate the source code into byte code. Java interpreter converts the byte code into machine level representation. Byte Code: -A highly optimized set of instructions to be executed by tehe java runtime system, known as java virtual machine (JVM). -Not executable code. Java Virtual Machine (JVM): - Need to be implemented for each platform. - Although the details vary from machine to machine, all JVM understand the same byte code.

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

Java compiler produces an intermediate code known as byte code for a machine, known as JVM. It exists only inside the computer memory.
Java Program Java Compiler Virtual Machine

Machine code is generated by the java interpreter by acting as an intermediary between the virtual machine and real machine.

Bytecode
05/07/2008

Java Interpreter

Machine Code
7

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

Fundamentally based on OOP


Classes and Objects Efficient re-use of packages such that the programmer only cares about the interface and not the implementation The object model in java is simple and easy to extend.

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

Write-Once Run-Anywhere Changes in system resources will not force any change in the program. The Java Virtual Machine (JVM) hides the complexity of working on a particular platform Convert byte code into machine level representation.

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

Designed with the intention of being secure


No pointer arithmetic or memory management! Strict compile time and run time checking of data type. Exception handling It verify all memory access Ensure that no viruses are communicated with an applet.

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

10

Java grew up in the days of the Internet


Inherently network friendly Original release of Java came with Networking libraries Newer releases contain even more for handling distributed applications
RMI, Transactions

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

11

Handles multiple tasks simultaneously. Java runtime system contains tools to support multiprocess synchronization and construct smoothly running interactive systems.

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

12

Java performance is slower than C Provisions are added to reduce overhead at runtime. Incorporation of multithreading enhance the overall execution speed. Just-in-Time (JIT) can compile the byte code into machine code. Can sometimes be even faster than compiled C code!

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

13

Capable of dynamically linking a new class libraries, methods and objects. Java can use efficient functions available in C/C++. Installing new version of library automatically updates all programs

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

14

Java Applets Security Portability 1. Applets: Special java program that can transmitted over the network and automatically executed by a java-compatible web browser. 2. Security: Java compatible web browser can download java applets without fear of viral infection and malicious agent.

3. Portable: Java applets can be dynamically downloaded to all the various types of platforms connected to the internet
05/07/2008 Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU 15

.
The output of java compiler is not executable code.
Once JVM exists for a platform, any java program can run on it. The execution of byte code by the JVM makes java programs portable. Java program is confined within the java execution environment and cannot access the other part of the computer.

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

16

Java programs normally undergo five phases


Edit Programmer writes program (and stores program on disk) Compile Compiler creates bytecodes from program Load Class loader stores bytecodes in memory Verify Verifier ensures bytecodes do not violate security requirements Execute Interpreter translates bytecodes into machine language

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

17

Phase 1

Editor

Disk

Program is created in an editor and stored on disk in a file ending with .java. Compiler creates bytecodes and stores them on disk in a file ending with .class.

Phase 2

Compiler

Disk Primary Memory

Phase 3

Class Loader

Disk

.. . .. .

Class loader reads .class files containing bytecodes from disk and puts those bytecodes in memory.

Phase 4

Bytecode Verifier

Primary Memory Bytecode verifier confirms that all bytecodes are valid and do not violate Javas security restrictions.

.. . .. .

Primary Memory

Phase 5

Interpreter

.. . .. Md. Samsuzzaman ,Lecturer . Faculty

Interpreter reads bytecodes and translates them into a language that the computer can understand, possibly storing data values as the program executes.

05/07/2008

of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

18

1.

Development tools-part of java development kit (JDK). Classes and methods-part of Java Standard Library (JSL), also known as Application Programming Interface (API). JDK: Appletviewer ( for viewing applets) Javac (Compiler) Java (Interpreter) Javap (Java disassembler) Javah (for C header files) Javadoc ( for creating HTML description) Jdb (Java Debugger)

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

19

2. Application Package Interface (API) Contains hundreds of classes and methods grouped into several functional packages: Language Support Package Utility Packages Input/Output Packages Networking Packages AWT Package Applet Package

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

20

1. Java 1.0 2. Java 1.1 (Add new library, redefine applet handling and reconfigured many features.) 3. Java 2 (Second generation). Version no:1.2 (Internal version number of java library). Also known as J2SE [ Java 2 Platform Standard Edition]. - Add swing, the collection framework, enhanced JVM etc. 4. J2SE 1.3 5. J2SE 1.4 6. J2SE 1.5 7. J2SE 1.6

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

21

Three versions of the Java 2 Platform, targetted at different uses Java 2 Micro Edition (J2ME) Very small Java environment for smart cards, pages, phones, and set-top boxes Subset of the standard Java libraries aimed at limited size and processing power Java 2 Standard Edition (J2SE) The basic platform J2SE can be used to develop client-side standalone applications or applets. Java 2 Enterprise Edition (J2EE) For business applications, web services, mission-critical systems Transaction processing, databases, distribution, replication

05/07/2008

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

22

Chapter One of the text book. Software Used for the Course: 1. Java 2 (Version 6) 2. NetBean IDE 3. J creature - Sun.java.com

Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU Mosarratj Jahan, Dept. of CSE, DU

23

You might also like