Chapter 0111

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 34

Faculty of Computer

Science

Subject: Advance JAVA


Lecturer: Ajmal Rahmati
Java Programming Chapter 01

CHAPTER#-01
Java Programming Chapter 01

Introduction to JAVA programming


Java Programming Chapter 01

What is Java?
• Java is a programming language and a platform. Java is a high level, robust, object-oriented
and secure programming language.

• Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the
year 1995.

• James Gosling is known as the father of Java. Before Java, its name was Oak. Since Oak was
already a registered company, so James Gosling and his team changed the Oak name to Java.

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.
Java Programming Chapter 01

Application
1.Desktop Applications such as acrobat reader, media player,
antivirus, etc.
2.Web Applications such as irctc.co.in, javatpoint.com, etc.
3.Enterprise Applications such as banking applications.
4.Mobile
5.Smart Card
6.Robotics
7.Games, etc.
Java Programming Chapter 01

Types of Java Applications


There are mainly 4 types of applications that can be created using Java
programming:
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 etc. technologies are used for
creating web applications in Java.
Java Programming Chapter 01

Continue…
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 is
used for creating enterprise applications.
4) Mobile Application
An application which is created for mobile devices
is called a mobile application. Currently, Android is
used for creating mobile applications.
Java Programming Chapter 01

Java Editions
There are 3 platforms or editions of Java:
1) Java SE (Java Standard Edition)
It is a Java programming platform. It includes Java programming APIs such
as java.lang,java.io, java.net, java.util, java.sql, java.math etc. It includes
core topics like OOPs,Exception, Multithreading, I/O Stream, Networking,
AWT, Swing, etc.

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, Web Services, etc.

3) Java ME (Java Micro Edition)


It is a micro platform which is mainly used to develop mobile applications.
Java Programming Chapter 01

History of Java
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) Initially it was designed for small, embedded systems in
electronic appliances like set-top boxes.
3) Firstly, it was called "Greentalk" by James Gosling, and the 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 the U.S.A., France, Germany,
Romania, etc.
Java Programming Chapter 01

6) In 1995, Oak was renamed as "Java“.


7) Notice that Java is just a name, not an acronym.
8) Initially developed by James Gosling at Sun
Microsystems (which is now a subsidiary of Oracle
Corporation) and released in 1995.
9) In 1995, Time magazine called Java one of the Ten
Best Products of 1995.
Java Programming Chapter 01

James Arthur Gosling, often referred to as "Dr. Java", (born May 19, 1955) is a Canadian computer scientist,
best known as the founder and lead designer behind the java programming Language.

Wikipedia
Java Programming Chapter 01

Features of Java
Java Programming Chapter 01
Java Programming Chapter 01

1. Simple
java is very easy to learn, and its syntax is simple, clean and easy to understand.
According to Sun Microsystem, 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.
2. Object Oriented
Java is an object-oriented programming language.
Basic concepts of OOPs are:
1. Object
2. Class
3. Inheritance
4. Polymorphism
5. Abstraction
6. Encapsulation
Java Programming Chapter 01

3. Platform Independent
Java is platform independent because it is different from other
languages like C, C++, etc. which are compiled into platform
specific machines.
Java code can be executed 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).
Java Programming Chapter 01

4. Secured
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
Java Programming Chapter 01

5. Robust
The English mining of Robust is strong. Java is robust
because:
1. It uses strong memory management.
2. There is a lack of pointers that avoids security
problems.
3. Java provides automatic garbage collection.
4. There are exception handling and the type checking
mechanism in Java. All these points make Java robust.
Java Programming Chapter 01

6. 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.
7. Portable
Java is portable because it facilitates you to carry the Java bytecode
to any platform.
Java Programming Chapter 01

8. 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++).
9. Distributed
Java is distributed because it facilitates users to create distributed
applications in Java.
Java Programming Chapter 01

10. Multi-threaded
Multithreading allows the execution of multiple parts of a program
at the same time.
11. Dynamic
Java is considered as dynamic because of Bytecode. A source code
written in one platform, the same code can be executed in any
platform.
12. Interpreted
java is a interpreted language.
Java Programming Chapter 01

First Java Program


We can write a simple hello Java program easily after installing the JDK.
To create a simple Java program, you need to create a class that contains the
main method. Let's understand the requirement first.
Requirements:
1. Install the JDK if you don't have installed.
2. Set JDK path.
3. Create the Java program
4. Compile and run the Java program
Java Programming Chapter 01

Example

class Simple{
public static void main(String args[]){
System.out.println("Hello Java");
}
}
Java Programming Chapter 01

Compilation Flow:
When we compile Java program using javac tool, the Java compiler
converts the source code into byte code.
Java Programming Chapter 01
Java Programming Chapter 01

Parameters used in First Java Program


Let's see what is the meaning of class, public, static,
void, main, String[], System.out.println().
1. class keyword is used to declare a class in Java.
2. public keyword is an access modifier that represents
visibility. It means it is visible to all.
3. static is a keyword. If we declare any method as static, it is
known as the static method. The core advantage of the
static method is that there is no need to create an object to
invoke the static method. The main() method is executed by
the JVM, so it doesn't require creating an object to invoke
the main() method. So, it saves memory.
Java Programming Chapter 01

4. void is the return type of the method. It means it


doesn't return any value.
5. main represents the starting point of the program.
6. String[] args or String args[] is used for command
line argument. We will discuss it in coming section.
7. System.out.println() is used to print statement.
Here, System is a class, out is an object of the
PrintStream class, println() is a method of the
PrintStream class. We will discuss the internal
working of System.out.println() statement in the coming
section.
Java Programming Chapter 01

What is JVM?
JVM (Java Virtual Machine) is an abstract machine. It is
called a virtual machine because it doesn't physically
exist. It is a specification that provides a runtime
environment in which Java bytecode can be executed.
The JVM performs the following main tasks:
• Loads code
• Verifies code
• Executes code
• Provides runtime environment
Java Programming Chapter 01

What is JRE?
JRE is an acronym for Java Runtime Environment. The Java Runtime
Environment is a set of software tools which are used for developing
Java applications.
It is used to provide the runtime environment. It is the implementation
of JVM. It physically exists. It contains a set of libraries + other files
that JVM uses at runtime.
Java Programming Chapter 01
Java Programming Chapter 01

What is JDK?
JDK is an acronym for Java Development Kit. The Java Development
Kit (JDK) is a software development environment which is used to
develop Java applications and applets.
It physically exists. It contains JRE + development tools.
Java Programming Chapter 01
Java Programming Chapter 01

Suggested Reading for Lecture:


Introduction to Java Programming By: Y. Daniel Liang 8th edition
java how to program By: Paul Deitel and Harvey Deitel 9th edition
Review Questions:
Thank You
For Your Patience

Thought of Day
‫همیشه امید داشته باش چون همیشه فردایی هست‬

You might also like