0% found this document useful (0 votes)
33 views44 pages

Java Programming Language Overview

Java is a high-level, robust, object-oriented programming language and platform used across various applications, including desktop, web, enterprise, mobile, and embedded systems. It features portability, security, and a rich set of APIs, with four main editions: Java SE, Java EE, Java ME, and JavaFX. The language's history began in the early 1990s, originally designed for interactive television, and has evolved to support a wide range of programming paradigms and applications.

Uploaded by

Chakra Rawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views44 pages

Java Programming Language Overview

Java is a high-level, robust, object-oriented programming language and platform used across various applications, including desktop, web, enterprise, mobile, and embedded systems. It features portability, security, and a rich set of APIs, with four main editions: Java SE, Java EE, Java ME, and JavaFX. The language's history began in the early 1990s, originally designed for interactive television, and has evolved to support a wide range of programming paradigms and applications.

Uploaded by

Chakra Rawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java

Lecture I
Application, Platform History, features, PPPl vs
OOP, JVM, JRE
What is Java?
• Java is a programming language and a platform.
• Java is a high level, robust, object-oriented and secure programming
language.
Platform:
• Any hardware or software environment in which a program runs, is
known as a platform.
• Since Java has a runtime environment (JRE) and API, it is called a
platform.
Application
There are many devices where Java is currently used. Some of them are as
follows:
• Desktop Applications such as acrobat reader, media player, antivirus, etc.
• Web Applications
• Enterprise Applications such as banking applications.
• Mobile
• Embedded System
• Smart Card
• Robotics
• Games, etc.
Types of Java Applications
1) Standalone Application
Standalone applications are also known as desktop applications or
window-based applications.
These are traditional software that we need to install on every machine.
Examples of standalone application are Media player, antivirus, etc. AWT
and Swing are used in Java for creating standalone applications.
2) Web Application
• An application that runs on the server side and creates a dynamic page
is called a web application.
Currently, Servlet, JSP, Struts, Spring, Hibernate, JSF, etc. technologies
are used for creating web applications in Java.
Cont….
3) Enterprise Application
• An application that is distributed in nature, such as banking applications,
etc. is called enterprise application.
• It has advantages of the high-level security, load balancing, and
clustering.
• In Java, EJB (Enterprise Java Bean) is used for creating enterprise
applications.
4) Mobile Application
• An application which is created for mobile devices is called a mobile
application.
• Currently, Android and Java ME (Micro Edition) are used for creating
mobile applications.
Java Platforms / Editions
4 editions of Java
1) Java SE (Java Standard Edition)
• It is a Java programming platform.
• It includes Java programming APIs such as [Link], [Link],
[Link], [Link], [Link], [Link] etc.
• It includes core topics like OOPs, String, Regex, Exception,
Inner classes, Multithreading, I/O Stream, Networking, AWT
(Abstract Window Toolkit), Swing, Reflection, Collection, etc.
Cont…
2) Java EE (Java Enterprise Edition)
• It is an enterprise platform which is mainly used to develop web and
enterprise applications.
• It is built on the top of the Java SE platform. It includes topics like
Servlet, JSP (Java Server Pages), Web Services, EJB (Enterprise JavaBeans), JPA
(Java Persistence API) , etc.
3) Java ME (Java Micro Edition)
• It is a micro platform which is mainly used to develop mobile
applications.
4) JavaFX
• It is used to develop rich internet applications. It uses a light-weight user
interface API.
History of Java
• Java was originally designed for interactive television, but it was too
advanced technology for the digital cable television industry at the
time.
• The history of java starts with Green Team. Java team members (also
known as Green Team), initiated this project to develop a language for
digital devices such as set-top boxes, televisions, etc. However, it was
suited for internet programming. Later, Java technology was
incorporated by Netscape.
• The principles for creating Java programming were
"Simple, Robust, Portable, Platform-independent, Secured, High
Performance, Multithreaded, Architecture Neutral, Object-Oriented,
Interpreted and Dynamic".
Cont…..
1) James Gosling, Mike Sheridan, and Patrick
Naughton initiated the Java language project in June 1991.
The small team of sun engineers called Green Team.
2) Originally designed for small, embedded systems in
electronic appliances like set-top boxes.
3) Firstly, it was called "Greentalk" by James Gosling, and
file extension was .gt.
4) After that, it was called Oak and was developed as a part
of the Green project.
5) Why Oak? Oak is a symbol of strength and chosen as a national tree of
many countries like U.S.A., France, Germany, Romania, etc.
6) In 1995, Oak was renamed as "Java" because it was already a trademark by
Oak Technologies.
Why Java Programming named "Java"?
7) Why had they chosen java name for java language?
The team gathered to choose a new name. The suggested words were
"dynamic", "revolutionary", "Silk", "jolt", "DNA", etc. They wanted
something that reflected the essence of the technology: revolutionary,
dynamic, lively, cool, unique, and easy to spell and fun to say.
According to James Gosling, "Java was one of the top choices along
with Silk". Since Java was so unique, most of the team members preferred
Java than other names.
8) Java is an island of Indonesia where first coffee was produced (called
java coffee).
9) Notice that Java is just a name, not an acronym.
Cont…
• JDK Alpha and Beta (1995)
• JDK 1.0 (23rd Jan 1996)
• JDK 1.1 (19th Feb 1997)
• J2SE 1.2 (8th Dec 1998)
• J2SE 1.3 (8th May 2000)
• J2SE 1.4 (6th Feb 2002)
• J2SE 5.0 (30th Sep 2004)
• Java SE 6 (11th Dec 2006)
• Java SE 7 (28th July 2011)
• Java SE 8 (18th March 2014)
• Java SE 9 (21st Sep 2017)
• Java SE 10 (20th March 2018)
Features of Java
The primary objective of Java programming language creation was to
make it portable, simple and secure programming language.
Apart from this, there are also some excellent features which play an
important role in the popularity of this language.
A list of most important features of Java language:
• Simple
• Object-Oriented
• Portable
• Platform independent
• Secured
Cont….
• Robust
• Architecture neutral
• Interpreted
• High Performance
• Multithreaded
• Distributed
• Dynamic
Simple
• Java is very easy to learn, and its syntax is simple, clean and easy to
understand.
• According to Sun, Java language is a simple programming language
because:
• Java syntax is based on C++
(so easier for programmers to learn it after C++).
• Java has removed many complicated and rarely-used features, for
example, explicit pointers, operator overloading, etc.
• There is no need to remove unreferenced objects because there is an
Automatic Garbage Collection in Java.
Object-oriented
• 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 incorporates both data and behavior.
• Object-oriented programming (OOPs) is a methodology that simplifies software
development and maintenance by providing some rules.
Basic concepts of OOPs are:
• Object
• Class
• Inheritance
• Polymorphism
• Abstraction
• Encapsulation
Simple
• Java is very easy to learn, and its syntax is simple, clean and easy to
understand.
• According to Sun, Java language is a simple programming language
because:
• Java syntax is based on C++
(so easier for programmers to learn it after C++).
• Java has removed many complicated and rarely-used features, for
example, explicit pointers, operator overloading, etc.
• There is no need to remove unreferenced objects because there is an
Automatic Garbage Collection in Java.
Platform Independent
• Java is platform independent because it is different from other languages
like C, C++, etc.
• which are compiled into platform specific machines while Java is a write
once, run anywhere language. 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 a software-based platform.
• The Java platform differs from most other platforms in the sense that it is a
software-based platform that runs on the top of other hardware-based
platforms.
• It has two components:
• Runtime Environment
• API(Application Programming Interface)
Platform independent
• Java code can be run on multiple
platforms, for example, 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).
Cont……
• Java is very easy to learn, and its syntax is simple, clean and easy to
understand.
• According to Sun, Java language is a simple programming language
because:
• Java syntax is based on C++
(so easier for programmers to learn it after C++).
• Java has removed many complicated and rarely-used features, for
example, explicit pointers, operator overloading, etc.
• There is no need to remove unreferenced objects because there is an
Automatic Garbage Collection in Java.
Secured
Cont……
Java is best known for its security. With Java, we can develop virus-free systems.
Java is secured because:
• No explicit pointer
• Java Programs run inside a virtual machine sandbox
• Classloader: Classloader in Java is a part of the Java Runtime Environment(JRE)
which is used to load Java classes into the Java Virtual Machine dynamically. It
adds security by separating the package for the classes of the local file system
from those that are imported from network sources.
• Bytecode Verifier: It checks the code fragments for illegal code that can violate
access right to objects.
• Security Manager: It determines what resources a class can access such as
reading and writing to the local disk.
Java language provides these securities by default. Some security can also be
provided by an application developer explicitly through SSL, JAAS, Cryptography,
etc.
Robust
Robust simply means strong. Java is robust because:
• It uses strong memory management.
• There is a lack of pointers that avoids security problems.
• There is automatic garbage collection in java which runs on
the Java Virtual Machine to get rid of objects which are not
being used by a Java application anymore.
• There are exception handling and the type checking
mechanism in Java. All these points make Java robust.
Architecture-neutral
• 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.
However, it occupies 4 bytes of memory for both 32 and 64-bit
architectures in Java.
Portable
• Java is portable because it facilitates you to carry the
Java bytecode to any platform.
• It doesn't require any implementation.
High-performance
• Java is faster than other traditional interpreted
programming languages because Java bytecode is
"close" to native code.
• It is still a little bit slower than a compiled language
(e.g., C++).
• Java is an interpreted language that is why it is slower
than compiled languages, e.g., C, C++, etc.
Distributed
• Java is distributed because it facilitates users to create
distributed applications in Java.
• RMI(Remote Method Invocation) and EJB are used for
creating distributed applications.
• This feature of Java makes us able to access files by
calling the methods from any machine on the
internet.
RMI and EJB ?
RMI ?
The RMI (Remote Method Invocation) is an API that provides a
mechanism to create distributed application in java. The RMI allows an
object to invoke methods on an object running in another JVM.
What is EJB ?
• EJB is an acronym for enterprise java bean. It is a specification
provided by Sun Microsystems to develop secured, robust and
scalable distributed applications.
Multi-threaded
• A thread is like a separate program, executing concurrently.
• We can write Java programs that deal with many tasks at
once by defining multiple threads.
• The main advantage of multi-threading is that it doesn't
occupy memory for each thread. It shares a common
memory area.
• Threads are important for multi-media, Web applications,
etc.
Dynamic
• Java is a dynamic language.
• It supports dynamic loading of classes.
It means classes are loaded on demand. It also
supports functions from its native languages, i.e., C and
C++.
• Java supports dynamic compilation and automatic
memory management (garbage collection).
What is Java Platform?
• Java platform is a collection of programs that help to develop and run
programs written in the Java programming language.
• Java platform includes an execution engine, a compiler, and a set of
libraries. JAVA is platform-independent language.
• It is not specific to any processor or operating system.
Difference between Procedural Programming and Object Oriented
Programming
Procedural Programming Object Oriented Programming
• In procedural programming, program is divided into Combine into a single unit both data and functions that
small parts called functions. operate on that data. Such a unit is called object.
• Procedural programming follows top down approach. • Object oriented programming follows bottom up
approach.
• There is no access specifier in procedural • Object oriented programming have access specifiers
programming. like private, public, protected etc.
• Adding new data and function is not easy. • Adding new data and function is easy.
• Procedural programming does not have any proper • Object oriented programming provides data hiding so
way for hiding data so it is less secure. it is more secure.
• In procedural programming, overloading is not • Overloading is possible in object oriented
possible. programming.
• In procedural programming, function is more • In object oriented programming, data is more
important than data. important than function.
• Procedural programming is based on unreal world. • Object oriented programming is based on real world.
• Examples: C, FORTRAN, Pascal, Basic etc. • Examples: C++, Java, Python, C# etc.
Java Applet and Application
• An applet is a Java program that runs in a Web browser.
• You can write your Java applet and include it in an HTML page, much in the
same way an image is included.
• When you use a Java-enabled browser to view an HTML page that contains
an applet, the applet's code is transferred to your system and is run by the
browser's Java virtual machine.
• The HTML document contains tags, which specify the name of the Java
applet and its Uniform Resource Locator (URL).
• The URL is the location at which the applet bytecodes reside on the Internet.
• When an HTML document containing a Java applet tag is displayed, a Java-
enabled Web browser downloads the Java bytecodes from the Internet and
uses the Java virtual machine to process the code from within the Web
document.
• These Java applets are what enable Web pages to contain animated graphics
or interactive content.
Applications are stand-alone programs that do not require the use of a
browser.
• Java applications run by starting the Java interpreter from the
command line and by specifying the file that contains the compiled
application.
• Applications usually reside on the system on which they are deployed.
Applications access resources on the system, and are restricted by
the Java security model.
JDK, JRE and JVM
JAVA DEVELOPMENT KIT
• The Java Development Kit (JDK) is a software development
environment used for developing Java applications and applets.
• It includes the Java Runtime Environment (JRE), an interpreter/loader
(Java), a compiler (javac), an archiver (jar), a documentation
generator (Javadoc) and other tools needed in Java development.
JAVA RUNTIME ENVIRONMENT
• JRE stands for “Java Runtime Environment” and may also be written
as “Java RTE.”
• 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.
JAVA VIRTUAL MACHINE (JVM)
• JVM (Java Virtual Machine) is an abstract machine.
• It is a specification that provides runtime environment in which java
bytecode can be executed.
• JVMs are available for many hardware and software platforms
(i.e. JVM is platform dependent).
What is JVM?
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.
What it does
The JVM performs following operation:
• Loads code
• Verifies code
• Executes code
• Provides runtime environment
JVM provides definitions for the:
• Memory area
• Class file format
• Register set
• Garbage-collected heap
• Fatal error reporting etc.
JDK, JRE, JVM
Java’s Lineage
• Java is related to C++, which is a direct descendant of C.
• Much of the character of Java is inherited from these two languages.
• From C, Java derives its syntax.
• Many of Java’s object oriented features were influenced by C++.
• In fact, several of Java’s defining characteristics come from or are
responses to its predecessors.
• Moreover, the creation of Java was deeply rooted in the process of
refinement and adaptation that has been occurring in computer
programming languages for the past several decades.
How Java Changed the Internet?
• The Internet helped catapult Java to the forefront of programming, and
Java, in turn, had a profound effect on the Internet.
• In addition to simplifying web programming in general, Java innovated a
new type of networked program called the applet that changed the way
the online world thought about content.
• Java also addressed some of the thorniest issues associated with the
Internet: portability and security
• JAVA innovated a new type of networked program called the applet that
changed the way the online world thought about content.
• Applet is a special type of program that is embedded in the webpage to
generate the dynamic content. It runs inside the browser and works at
client side.

• Security : JAVA achieved this protection by confining(restrict) an applet to


the JAVA execution environment and not allowing its access to other parts
of the computer

• Portability: In case of an applet, the same applet must be able to be


downloaded and executed by the wide variety of CPU’s , operating systems
and browsers connected to the internet.
Bytecode
Advantage of Java Bytecode
• Platform independence is one of the soul reasons for which James
Gosling started the formation of java and it is this implementation of
bytecode which helps us to achieve this.
• Hence bytecode is a very important component of any java program.
• The set of instructions for the JVM may differ from system to system
but all can interpret the bytecode.
• A point to keep in mind is that bytecodes are non-runnable codes and
rely on the availability of an interpreter to execute and thus the JVM
comes into play.
• Bytecode is essentially the machine level language which runs on the
Java Virtual Machine.
• Whenever a class is loaded, it gets a stream of bytecode per method
of the class.
• Whenever that method is called during the execution of a program,
the bytecode for that method gets invoked. Javac not only compiles
the program but also generates the bytecode for the program. Thus,
we have realized that the bytecode implementation makes Java a
platform-independent language.
• This helps to add portability to Java which is lacking in languages like
C or C++
Servlets: Java on the Server Side
• A servlet is a small program that executes on the server.
• Just as applets dynamically extend the functionality of a web browser,
servlets dynamically extend the functionality of a web server. Thus,
with the advent of the servlet, Java spanned both sides of the
client/server connection.
• Servlets are used to create dynamically generated content that is then
served to the client.
• Because servlets (like all Java programs) are compiled into bytecode
and executed by the JVM, they are highly portable. Thus, the same
servlet can be used in a variety of different server environments. The
only requirements are that the server support the JVM and a servlet
container.

You might also like