0% found this document useful (0 votes)
50 views24 pages

Java Introduction

Uploaded by

Kalpana Pal
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
0% found this document useful (0 votes)
50 views24 pages

Java Introduction

Uploaded by

Kalpana Pal
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 24

INTRODUCTION TO JAVA

ROGRAMMING

Dr. Archana B Saxena


Professor
archanabsaxena@gmail.com
04/23/24 Introduction to Java 2

Reference Books
• The complete Reference Java2(10th Edition)
• Herbelt Schildt, Tata Mc Graw Hill
• Object Oriented Programming with C++ and Java
• Debasis Samanta, Perntice Hall of India
• Inside Java Virtual Machine”, 2nd Ed
• Bill Vanners , TMH,
• Java How to Program
• Paul Dietel and Harvey Deitel ,PHI, 8th Ed., 2010
04/23/24 Introduction to Java 3

History of Java
• Java is a general purpose, object oriented programming language
platform developed by Sun Microsystems in 1991,
• Java was conceived by James Gosling, Patrick Naughton, Chris
Warth, Ed frank and Mike Sheridan at sun Microsystems.
• Firstly it was called “Greentalk” by James Gosling and file extension
was .gt.
• Later renamed “Oak”, finally but renamed “java” in 1995.
• Java is an island in Indonesia. It is very famous for coffee, James
Gosling is very fond of coffee.
• Java technology was incorporated by “Netscape”
• In 1995, Time magzine called java one of the best products of
1995.
• JDK (Java Development Kit) 1.0 released in January 23, 1996.
04/23/24 Introduction to Java 4

• The idea is to create a platform independent language that could be


used to produce code that would run on a variety of CPUs under
differing environments.
• It is designed for the development of software for consumer
electronics devices like TV,VCRs, toasters and such other
electronic machine.
• This new language is based on C and C++ but removed features of
C and C++ that were considered as problems in these languages
and this makes java reliable , simple and robust language.
• Java is not replacement of C++, They both are designed to solve
different set of problems , so can coexist for many years.
04/23/24 Introduction to Java 5
04/23/24 Introduction to Java 6

Overlapping C, C++ and Java

C++ Java

C
04/23/24 Introduction to Java 7

Java Extraction and Creation


• Java is related to C++ which is direct descendent of C.
Much of its characteristics java derive from these two
languages.
• Java derives its syntax from C, and its OOPs features
were influenced by C++.
• Primary motivation behind java was need of platform
independent language that can run on any electronic
device.
• The second force behind java was WWW (World wide
Web)
04/23/24 Introduction to Java 8

JAVA Vs C++
• No More header files, Typedefs, Defines, or Preprocessor -
Packages
• No More Structures or Unions –Instance variables,No Enums
• No More Functions –only methods
• No More Multiple Inheritance but support interfaces.
• Java does not support global variable.
• No More Goto Statements
• No More Operator Overloading
• No More Pointers
• Java does not have template class as in C++
• No More Automatic Coercions :Datatype conversion
• Java had replaced the destructor function within a finalize()
function.
04/23/24 Introduction to Java 9

Types of java program


• Java Core
• Java Internet
• Exception Handling
• JSP
• Packages
• JDBC
• Java Bean
• Distributed Programing
• I/O Handler
• Networking
• Interfaces
• Multithreaded
• Java Applet
• Java Multimedia
• Java Windows toolkit (AWT)
• Java Swing
• Java Script
04/23/24 Introduction to Java 10

Platform Dependent
04/23/24 Introduction to Java 11

Java Programs are Platform independent


04/23/24 Introduction to Java 12

Platform Independent programs


• Java technology applications are written in java
programing language and compiled to bytecode.
Bytecode is executed on java platform. The software that
provides you with a runnable java platform is called
JRE[Java Runtime Environment]. A complier included in
the JDK[Java development Kit] is used to convert java
source code to bytecode.
04/23/24 Introduction to Java 13

Java Platforms

• Java SE:
• Java Middleware Editions
• Java server cards
04/23/24 Introduction to Java 14

Java Features
• Java is simple, small and familiar : Because java inherits the C/C++
syntax and many of OOPS features of C++.
Java does not use pointers, preprocessor header files, goto
statement and many more. It also eliminates operator overloading
and multiple inheritance.
It is modeled on C and C++ , so syntax is familiar.
• Complied and Interpreted: Java is two stage system that combines
both compilation and interpretation. Firstly java compiler translate
source code into bytecode instruction, then java interpreter converts
bytecode into machine code and run java program.
• Platform Independent and Portable: java programs can be easily
moved from one computer system to another, anywhere and
anytime. Changes in OS, processor and system resources will not
force and changes in java program. Because: I : java compiler
generates bytecode not machine language which is machine
independent. II:size of primitive data types are machine independent.
• Object Oriented: java is true object oriented. All program code and
data reside within objects and classes.
04/23/24 Introduction to Java 15

• Java is secure and robust: java program is secure by confining a java


program to java execution environment and not allowing it access to other
parts of the computer. java programs are robust as they are build for
multiplatform environment. Moreover a program is said to be robust if it
handles memory management and exception condition. Java virtually
eliminates these problems by managing memory allocation and de-allocation
for you. Java also provides object oriented exception handling.
• Java is distributed : java is designed for the distributed environment of the
Internet, because it handles TCP/IP protocols. Java applications can open
and access remote objects on internet as easily as they do in a local system.
• Java is multithreaded: Means handling multiple tasks simultaneously. This
means we need not wait for the application to finish one tasks before
beginning another.
• Java is dynamic: java is capable of dynamically linking in new class
libraries , methods and objects. Java can also determine the type of class
through a query, making it possible to either dynamically link or abort the
program, depending on the response.
04/23/24
Working of Java
Introduction to Java 16

• - Java solves the problem of platform-independence by using


byte code.
• - The Java compiler does not produce native executable code for
a particular machine like a C compiler would. Instead it produces
a special format called byte code.
• Java byte code starts with 0X CA FE BA BE
This looks a lot like machine language, but unlike machine
language Java byte code is exactly the same on every platform.
• This byte code fragment means the same thing on a Solaris
workstation as it does on a Macintosh PowerBook and same
code will run on any electronic device that has processor and
JVM.
04/23/24 Introduction to Java 17

• Java programs that have been compiled into byte


code still need an interpreter to execute them on
any given platform.
• The interpreter reads the byte code and translates
it into the native language of the host machine on
the fly.
• The most common such interpreter is Sun's
program java (with a little j). Since the byte code is
completely platform independent, only the
interpreter and a few native libraries need to be
ported to get Java to run on a new computer or
operating system.
• The rest of the runtime environment including the
compiler and most of the class libraries are written
04/23/24 Introduction to Java 18

Bytecode
The key that solves both security and portability problems
is the Bytecode, output of java compiler which is not
executable code.
It is highly optimized set of instructions designed to be
executed by the java runtime system, which is called the
java Virtual Machine(JVM). JVM is an interpreter for
bytecode.
Translating a java program into bytecode makes it much
easier to run a program in a wide variety of environments
because only the JVM needs to be implemented for each
platform. Once a runtime package exists for given
system, any java program can run on it.
04/23/24 Introduction to Java 19

Although the details of JVM will differ from platform to


platform , all understand the same java bytecode.
Thus , the execution of bytecode by the JVM is the
easiest way to create truly portable programs.
The fact that a java program is executed by JVM also
helps to make it secure because the JVM is in control, it
contain the program and prevent it from generating side
effects outside the system.
When a program is complied to an intermediate form and
the interpreted by a virtual machine, it runs slower than
it would run if complied to executed code. But in case of
java the difference two is not so great because
bytecode is highly optimized, the use of bytecode
enables the JVM to execute programs much faster that
you might expect.
04/23/24 Introduction to Java 20

• Furthermore not all sequence of bytecode are compiled-


only those that will benefit from compilation.
• The remaining code is simple interpreted. JIT Time(Just
In )still yields a significant performance boost.
• Even when dynamic compilation is applied to bytecode,
the portability and safety features still apply, because the
JVM is still in charge of the execution environment.
04/23/24 Introduction to Java 21

JVM an Emulator
04/23/24 Introduction to Java 22

JRE(Java Runtime Environment)


04/23/24 Introduction to Java 23

Java Development Kit


The java development kit comes with a collection of tools that
are used for developing and running java programs.
• Appletviewer (For viewing java applets): enables us to run
java applets with java compatible browser.
• Java(java interpreter): which runs java applets and
applications by reading and interpreting bytecode files.
• Javac (java complier): which translates java source code into
byte code files that interpreter can understand.
• Javadoc(for creating HTML documents): creates HTML
format documentation from java source code.
• Javap(java dis-assembler): which converts bytecode files
into a program description.
• Javah(for C header files)produce header files for use with
native methods.
• Jdb(java debugger)which helps to find errors in programs.
04/23/24 Introduction to Java 24
Types of Java Application
• Applications that do not use a graphical user
Interface (GUI)– they are similar to traditional
program written in C & C++.
• Applications using GUI- application that have
GUI like windows , form in VB.
• Applets – these programmes run on a web
page and requires a java enabled browser
like IE.
• Servlets- servlets do not have GUI but they
are widely used to extend the functionality of
web server.
• Packages –are collection of classes that can
be shared by applications and applets. They
are similar to the libraries provided by other
languages like C++. Java provides
packages.

You might also like