20ES3102 Java Programming Unit I Chapter 1 Introduction, History, Features and the Evolution of Java

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Java Programming Language


A Language for Professional Programmers
A.Raghuvira Pratap
Assistant Professor, CSE Department
pratapadimulam@vrsec.ac.in
A.Raghuvira Pratap , Asst. Professor, CSE Department 1
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Overview
• What is Java?

• History of Java and Evolution

• Why Java? Where it is Java used?

• Features of Java

• Java’s Magic: Byte Code

• How Java Differs from C and C++


A.Raghuvira Pratap , Asst. Professor, CSE Department 2
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Introduction
What is a Java Programming Language?
• It is a general-purpose high level compiled and interpreted
computer programming language designed to produce
programs that will run on any electronic device.

A.Raghuvira Pratap , Asst. Professor, CSE Department 3


20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.
• Java is a Platform.
– Platform means any hardware or software
environment in which a program runs.
• Since Java has its own Runtime Environment (JRE) it
referred as platform.
• Java is a software-only platform running on top of other,
hardware-based platforms.

A.Raghuvira Pratap , Asst. Professor, CSE Department 4


20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

History of Java Programming


• Who developed Java Programming?
• Developed by James Gosling, Mike Sheridan, and Patrick Naughton

• It was in the early 1990’s, when James Gostling came up with an idea
to develop small handheld device that remotely connects all home
appliances supports a programming language while working in Sun
Microsystems ( Later merged into Oracle Corporation).

A.Raghuvira Pratap , Asst. Professor, CSE Department 5


20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.
• Next Wave of Computing?
– Digitally controlled consumer devices.
• Small Embedded System in Electronic Appliances.
– Home Appliances like Set-Top Boxes, TV’s.
• New Product Designed and named Star *7
– They designed and built a new SPARC based software and handheld
wireless PDA (known as the Star7 or *7), with a 5" color LCD with touch
screen input, a new 16 bit 5:6:5 color.
• Star *7 was finished and demoed on September 3, 1992.
– One of the most interesting pieces of work that came out of it was a
business plan. User interface methodology which uses animation, audio,
spatial cues, gestures, agency, color, and fun. Fun and Engaging .
– Hardware and software combination, including a TV guide, a fully
functioning television remote control.
– Too Advanced and Expensive.
A.Raghuvira Pratap , Asst. Professor, CSE Department 6
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

• Emergence of World wide web


– Demanded portable programs.
Contd.
• Computer world divided itself into three competing comp’s of INTEL,
MACINTOSH & UNIX.
• New Language Initiation.
– Language designed for small scale applied to the internet in large scale.
– Switch from consumer electronic devices to Internet.
– Firstly, it was called "Green talk" by James Gosling and file extension was
.gt. After that, it was called Oak and was developed as a part of the Green
project.
• Why Oak? Earlier name of java was “OAK”.
– Tree, There was already a programming language called 'OAK', so they
decided to rename 'OAK'.
– "Dynamic", "revolutionary", "Silk", "jolt", "DNA"
– In 1995, Oak was renamed as “Java” because it was already a trademark by
Oak Technologies. After renaming ‘Oak’ to java they publicly released
Java on May,27,1995.
A.Raghuvira Pratap , Asst. Professor, CSE Department 7
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.
Why the Name “Java”?
• Java is an island of Indonesia where first coffee was produced
(called java coffee).
• Java is a Island Famous for Coffee seeds.
• In 1995, Time magazine called Java one of the Ten Best Products
of 1995.

A.Raghuvira Pratap , Asst. Professor, CSE Department 8


20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.
Where it is used?
• Desktop Applications.
– A desktop application means any software that can be installed on a
single computer (laptop or a desktop) and used to perform specific
tasks such as acrobat reader, media player, antivirus etc.

• Web Applications.
– A web based application is a software package that can be accessed
through the web browser.

9
A.Raghuvira Pratap , Asst. Professor, CSE Department 9
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.
• Mobile Applications.
– A mobile app is a software application designed to run on mobile
devices such as smartphones and tablet computers.

• Embedded Applications.
– A software application that permanently resides in an industrial or
consumer device.

A.Raghuvira Pratap , Asst. Professor, CSE Department 10


20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Java Features/Buzzwords/Advantages
• Java is a Simple/Familiar Language
• Java is Platform Independent.
• Java is Compiled and Interpreted.
• Java is Portable.
• Java is a Dynamic Language.
• Java is Secured.
• Java is Robust.
• Java is a Distributed Language.
• Java is a Multithreaded Language.
• Java is Architecture Neutral.
• Java is High in Performance
• Java is a OOP Language.
A.Raghuvira Pratap , Asst. Professor, CSE Department 11
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.
• Java is a Simple/Familiar Language:
• Simplicity of Java is the professional programmers could learn it quickly
and use effectively. [Familiar]
• From C, Java derives it Syntax and Many of Java’s OOP Features
inherited from C++.
• Java was designed to make it much easier to write bug free code.
[ Bug Free System ]
• Efficient Memory management [Automatic]
• Removed many confusing and/or rarely-used features e.g., structures,
unions, explicit pointers, typedef, operator overloading etc.
• Java Removes Complexity because it doesn’t use pointers, Storage Classes
and Go to Statements and java doesn’t support Multiple Inheritance.
• Java is a Platform Independent Language:
• The concept of Write-once-run-anywhere (known as the Platform
independent) is one of the important key feature of java language that
makes java as the most powerful language.
A.Raghuvira Pratap , Asst. Professor, CSE Department 12
Contd.
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

• Contd.
• The programs written on one platform can run on any platform provided
the platform must have the JVM.
• Java code can be run on multiple platforms e.g. Windows, Linux, Sun
Solaris, Mac/OS etc. Java code is compiled by the compiler and converted
into bytecode.
• This bytecode is a platform independent code because it can be run on
multiple platforms i.e. Write Once and Run Anywhere(WORA).
• How it is Platform Independent Java’s Magic : ‘Bytecode’:
• Java bytecode is the instruction set of the Java virtual machine.
• Byte code is Highly Optimized set of instructions of Java Specification.
• It is also called as intermediate code. Also referred as Error free code.
• Byte code is also called as portable code. It is a form of instruction set
designed for efficient execution by a software.
• Bytecode is the compiled format for Java programs. Once a Java program
has been converted to bytecode, it can be transferred as a input and
executed by Java Virtual Machine (JVM).
• Bytecode files generally have a .class extension.
A.Raghuvira Pratap , Asst. Professor, CSE Department 13
Contd.
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

• Java is a Robust Language.


• Java has the strong memory allocation and automatic garbage collection
mechanism.
• Java is garbage-collected language – JVM automatically deallocates the
memory blocks and programmers do not have to worry about deleting the
memory manually as in case of C/C++.[Automatic memory management
and garbage collection].
• It provides the powerful exception handling and type checking mechanism
as compare to other programming languages. [Strong type checking
mechanism].
• Compiler checks the program whether there any error and interpreter
checks any run time error and makes the system secure from crash.
• Java is a Secured Language:
• Java does not use memory pointers explicitly.
• Security manager determines the accessibility options of a class like reading
and writing a file to the local disk.
• Class loader: adds security by separating the package for the classes of the
local file system from those that are imported from network sources.
• Java uses the public key encryption system to allow the java applications to
transmit over the internet in the secure encrypted form.
A.Raghuvira Pratap , Asst. Professor, CSE Department 14
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.
• Java is a Compiled and Interpreted Language:
• Usually, a computer language can be either compiled or interpreted. Java
integrates the power of Compiled Languages with the flexibility of
Interpreted Languages.
• Java is a compiled programming language, but rather than compile straight
to executable machine code, it compiles to an intermediate binary form
called JVM byte code. The byte code is then compiled
and/or interpreted to run the program.
• Compilation  Java’s JVM Specific. Byte Code
• Interpretation  Native CPU Specific. Executable Object code
• Java is a Portable language:
• Java is portable because it facilitates you to carry the Java bytecode to any
platform. It doesn't require any implementation.
• In C/C++, the source code may run slightly differently on different
hardware platforms, but Java simplifies it. You can run Java bytecode on
any hardware that has a compliant JVM which can convert the bytecode
according to that particular machine.
A.Raghuvira Pratap , Asst. Professor, CSE Department 15
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

A.Raghuvira Pratap , Asst. Professor, CSE Department 16


Contd.
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

• Java is a Architecture Neutral.


• In the world of network it is essential that the applications must be
able to migrate easily to different computer systems.
• Not only to computer systems but to a wide variety of hardware
architecture and Operating system architectures as well.
• Java is architecture neutral because there are no implementation
dependent features,
– for example, the size of primitive types is fixed. In C programming, int
data type occupies 2 bytes of memory for 32-bit architecture and 4 bytes
of memory for 64-bit architecture.
• It's compiler generates an architecture-neutral object file format,
which makes the compiled code to be executable on many
processors, with the presence of Java runtime system.
• Java is a Dynamic Language:
• Java is considered to be more dynamic than C or C++ since it is
designed to adapt to an evolving environment.
• Java programs can carry an extensive amount of run-time
information that can be used to verify and resolve accesses to objects
at run-time.
A.Raghuvira Pratap , Asst. Professor, CSE Department 17
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.
• Contd.:
• The features expecting from the dynamic languages are automation,
memory management and exception handling, Non-static typing
mechanisms and specific syntax choices to promote better code readability
and significantly reduced code verbosity.
• Java is a distributed language:
• Java is distributed because it encourages users to create distributed
applications.
• In Java, we can split a program into many parts and store these parts on
different computers. A Java programmer sitting on a machine can access
another program running on the other machine.
• This feature in Java gives the advantage of distributed programming, which
is very helpful when we develop large projects. Java helps us to achieve this
by providing the concept of RMI (Remote Method Invocation) and EJB
(Enterprise JavaBeans).
• Java comes with an extensive library of classes for interacting, using
TCP/IP protocols such as HTTP and FTP, which makes creating network
connections much easier than in C/C++.

A.Raghuvira Pratap , Asst. Professor, CSE Department 18


Contd.
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

• Java is a Multithreaded Language.


• A thread is an independent path of execution within a program,
executing concurrently. Multithreaded means handling multiple
tasks simultaneously or executing multiple portions (functions) of
the same program in parallel.
• The code of java is divided into smaller parts and Java executes
them in a sequential and timely manner.
• Advantages:
– The main advantage of multithreading is that the maximum utilization
of resources is possible.
– It doesn’t occupy memory for each thread. It shares a common
memory area.
– There is no need to wait for the application to finish one task before
beginning another one.
– There is a decreased cost of maintenance. Also, It is time-saving.
– It improves the performance of complex applications.
A.Raghuvira Pratap , Asst. Professor, CSE Department 19
Contd.
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

• Java is High in Performance.


• The performance of Java is impressive for an interpreted language
because of its intermediate bytecode.
• Java provides high performance with the use of “JIT – Just In Time
compiler”, in which the compiler compiles the code on-demand
basis, that is, it compiles only that method which is being called.
This saves time and makes it more efficient
• Java architecture is also designed in such a way that it reduces
overheads during runtime. The inclusion of multithreading
enhances the overall execution speed of Java programs.
• Bytecodes generated by the Java compiler are highly optimized, so
Java Virtual Machine can execute them much faster.
• Java is an Object Oriented Paradigm supported language:
• Java is an object-oriented programming language. Everything in
Java is an object. Object-oriented means we organize our software as
a combination of different types of objects that incorporate both data
and behavior.
A.Raghuvira Pratap , Asst. Professor, CSE Department 20
Contd.
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

• Contd.
• Java supports major Object-Oriented programming features like
Encapsulation, Abstraction, and Inheritance.
• Almost everything in Java is an object. All programs and data live
within objects and classes. ‘Objects’ model Java rather than the
‘processes’. Java comes with an extensible set of classes organized in
packages.
• Object-oriented programming(OOPs) is a methodology that simplify
software development and maintenance by providing some rules.
• Basic concepts of OOPs are:
– Object
– Class
– Inheritance
– Polymorphism
– Abstraction
– Encapsulation

A.Raghuvira Pratap , Asst. Professor, CSE Department 21


20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.
• To some extend java is not considered as pure object oriented
programming .
• For any language to be pure object oriented it must follow these 6
points strictly.
1) It must have full support for Encapsulation and Abstraction
2) It must support Inheritance
3) It must support Polymorphism
4) All predefined types must be Objects
5) All user defined types must be Objects
6) Lastly, all operations performed on objects must be only through
methods exposed at the objects.

A.Raghuvira Pratap , Asst. Professor, CSE Department 22


20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

JDK , JRE & JVM


• Java Development Kit
– JDK is an acronym for Java Development Kit. It physically exists.
– It contains JRE + development tools + API.
– Java Development Kit (in short JDK) is Kit which provides the
environment to develop and execute(run) the Java program. JDK is a
kit(or package) which includes two things:
• Development Tools(to provide an environment to develop your java
programs)
• JRE (to execute your java program).
• Note : JDK is only used by Java Developers.
– The Java Development Kit (JDK) is a software development environment
used for developing Java applications.
• Java Compiler , Java Interpreter, Standard Class Libraries , JIT
Compiler, Applet Viewer, Java Debugger, a documentation generator
(javadoc) etc.
A.Raghuvira Pratap , Asst. Professor, CSE Department 23
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.
• Java Runtime Environment
– JRE is an acronym for Java Runtime Environment. It is used to
provide runtime environment.
– Java Runtime Environment (to say JRE) is an installation package
which provides environment to only run(not develop) the java
program(or application)onto your machine.
– JRE is only used by them who only wants to run the Java Programs
i.e. end users of your system.
– It is the implementation of JVM. It physically exists. It contains set
of libraries + other files that JVM uses at runtime.
– The Java Runtime Environment provides the minimum
requirements for executing a Java application; it consists of the Java
Virtual Machine (JVM), core classes, and supporting files.

A.Raghuvira Pratap , Asst. Professor, CSE Department 24


20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

JRE Vs JDK
JRE JDK
(Java Runtime Environment) (Java Development Kit)
It is an implementation of the Java Virtual Machine* It is a bundle of software that you can use to
which actually executes Java programs. develop Java based applications.

Java Runtime Environment is a plug-in needed for Java Development Kit is needed for developing
running java programs. java applications.
The JRE is smaller than the JDK so it needs less The JDK needs more Disk space as it contains
Disk space. the JRE along with various development tools.

The JRE can be downloaded/supported freely from The JDK can be downloaded/supported freely
oracle.com from
oracle.com/technetwork/java/javase/downloads/

It includes the JVM, Core libraries and other It includes the JRE, set of API classes
additional components to run applications and ,development tools Java compiler, Web start
applets written in Java. and additional files needed to write Java applets
and applications.
A.Raghuvira Pratap , Asst. Professor, CSE Department 25
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.
• Java Virtual Machine
– JVM (Java Virtual Machine) is an abstract Machine. It is a specification that
provides runtime environment in which java byte code can be executed.
– Java Virtual machine(JVM) is a very important part of both JDK and JRE
because it is contained or inbuilt in both.
– Whatever Java program you run using JRE or JDK goes into JVM and JVM
is responsible for executing the java program line by line hence it is also known
as interpreter.
– Different JVM is designed for different OS and Hardware.
– JVM is a platform dependent , Where Java is Platform independent
– It is:
• A specification, where working of Java Virtual Machine is specified. But
implementation provider is independent to choose the algorithm. Its
implementation has been provided by Oracle and other companies.
• An implementation, Its implementation is known as JRE (Java Runtime
Environment).
• Runtime Instance, Whenever you write java command on the command
prompt to run the java class, an instance of JVM is created.
A.Raghuvira Pratap , Asst. Professor, CSE Department 26
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.

A.Raghuvira Pratap , Asst. Professor, CSE Department 27


20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.

A.Raghuvira Pratap , Asst. Professor, CSE Department 28


20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Java: Write Once, Run Anywhere


• Consequence of Java’s history: platform-independence
Web page stored on
Click on link to Applet Unix server

Mac user running Safari


Virtual machine translates byte code to Byte code is
native Mac code and the Applet runs downloaded

Windows user running Internet Explorer Byte code


(part of web
page)

A.Raghuvira Pratap , Asst. Professor, CSE Department 29


20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Contd.
• Consequence of Java’s history: platform-independent

Web page stored on


Unix server

Mac user running Safari

Click on link to Applet


Byte code is
downloaded

Windows user running Internet Explorer


Virtual machine translates byte code to native Windows code and
the Applet is run
A.Raghuvira Pratap , Asst. Professor, CSE Department 30
20ES3102 Unit I Chapter 1 Introduction, History, Features and Differences

Differences C C++ Java


Procedural Programming Procedural, OOP, Generic OOP, Generic Programming
Programming Approach
Language Programming languages languages.
Executable in Native Compiled into Java byte
Compiled Source Code Executable in Native Code
Code code
Managed, using a
Memory management Manual Done, Manual Done,
garbage collector
Yes, very commonly used,
No pointers; references are
Pointers Yes, very commonly used. but some form of
used instead.
references available too.
Preprocessor Yes Yes No
String Type Character arrays Character arrays, objects Objects
Complex Data Types Structures, unions Structures, unions, classes Classes

Single class
Inheritance N/A Multiple class inheritance inheritance, multiple
interface implementation
Operator Overloading N/A Yes No
Automatic coercions Yes, with warnings if loss Yes, with warnings if loss Not at all if loss could occur;
(Conversion) could occur could occur must cast explicitly
Varied Parameters Yes Yes No
Goto Statement Yes Yes No

A.Raghuvira Pratap , Asst. Professor, CSE Department 31

You might also like