01 Java Introduction To Java
01 Java Introduction To Java
1
Introduction
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
2
History of Java
The history of Java is very interesting. 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".
3
History of Java(Cont’d)
Currently, Java is used in internet programming, mobile
devices, games, e-business solutions, etc. There are given
the significant points that describe the 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) 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.
4
Why Java named "Oak"?
5
Why Java Programming
named "Java"?
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.
Java is an island of Indonesia where first coffee was produced
(called java coffee).
Notice that Java is just a name, not an acronym.
Initially developed by James Gosling at Sun Microsystems
(which is now a subsidiary of Oracle Corporation) and released
in 1995.
In 1995, Time magazine called Java one of the Ten Best
Products of 1995.
JDK 1.0 released in(January 23, 1996).
6
Java Version History
Many java versions have been released till now. The current
stable release of Java is Java SE 10.
Java SE 8 (18th March 2014)
JDK Alpha and Beta (1995) (unstable) Java SE 9 (21st Sep 2017)
JDK 1.0 (23rd Jan 1996) (inner class not there) Java SE 10 (20th March 2018)
JDK 1.1 (19th Feb 1997) (JavaBeans, RMI,JDBC) Java SE 11(25th September 2018)
J2SE 1.2 (8th Dec 1998) (J2SE,J2EE,J2ME) Java SE 12 (19th March 2019)
J2SE 1.3 (8th May 2000) (hotspot JVM) Java SE13 (17th September 2019)
J2SE 1.4 (6th Feb 2002) (Regular Expression) Java SE 14(17th March 2020)
J2SE 5.0 (30th Sep 2004) (Major Update- Used Java SE 15(September 2020)
Metadata, Autoboxing/unboxing., for loop, improved in standard libraries ) Java SE 16(March 2021)
Java SE 6 (11th Dec 2006) (Scripting Language Support, Improved Web Java SE 17(September 2021)
Service support, JDBC 4.0 support)
Java SE 18(March 2022)
Java SE 19(September 2022)
Java SE 7 (28th July 2011)
7
Features of Java
1. Simple
2. Object-Oriented
3. Portable
4. Platform independent
5. Secured
6. Robust
7. Architecture neutral
8. Interpreted
9. High Performance
10. Multithreaded
11. Distributed
12. Dynamic
13. Automatic garbage Collection
8
RMI (Remote Method Invocation) is an API that provides a
mechanism to create distributed application in java.
Object-oriented
Java is an object-oriented programming language.
Everything in Java is an object.
21
OOP
Small
C++ Java Talk
22
Platform Independent
When we compile Java program using ‘javac’ tool, java
compiler converts the source code into byte code. Then,
Java Interpreter converts Byte Code to Machine
Dependent Code
Machine
Byte Code Interpreter Dependent Code
Simple.class 23
Applications
According to Sun, 3 billion devices run Java. There are
many devices where Java is currently used. Some of them
are as follows:
Desktop Applications such as acrobat reader, media
Mobile
Embedded System
Robotics
Games, etc.
24
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.
25
Types of Java Applications(Cont’d)
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 and Java ME are used for creating mobile
applications.
26
Java Platforms / Editions
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.
27
Java Platforms / Editions(Cont’d)
3) Java ME (Java Micro Edition)
It is a micro platform which is mainly used to develop mobile
applications.
4) Java FX
It is used to develop rich internet applications. It uses a light-
weight user interface API.
28
First Java Program
The requirement for Java program
1. For executing any java program, you need to Install
the JDK if you don't have installed it,
download the JDK and install it.
2. Set path of the jdk/bin directory.
http://www.javatpoint.com/how-to-set-path-in-java
3. Create the java program
4. Compile and run the java program
29
Simple program
class Simple
{
public static void main(String args[]){
System.out.println("Hello Java");
}
}
Save this file as ‘Simple.java’
30
Parameters used in First Java
Program
class keyword is used to declare a class in java.
public keyword is an access modifier which represents visibility. It means
it is visible to all.
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 to create an object to invoke the
main method. So it saves memory.
void is the return type of the method. It means it doesn't return any value.
main represents the starting point of the program.
String[] args is used for command line argument. We will learn it later.
System.out.println() is used to print statement. Here, System is a class,
out is the object of PrintStream class, println() is the method of
PrintStream class. We will learn about the internal working of
System.out.println statement later.
31
Compilation & Execution
When we compile Java program using ‘javac’
tool, java compiler converts the source code
into byte code. Then, Java Interpreter converts
Byte Code to Machine Dependent Code
Machine
Byte Code Interpreter Dependent
Code
Simple.class 32
How many ways can we write a Java
program
1) By changing the sequence of the modifiers, method prototype is not changed
in Java.
static public void main(String args[])
2) The subscript notation in Java array can be used after type, before the
variable or after the variable.
public static void main(String[] args)
public static void main(String []args)
public static void main(String args[])
3) You can provide var-args support to the main method by passing 3 ellipses
(dots)
public static void main(String... args)
4) Having a semicolon at the end of class is optional in Java.
class A{
static public void main(String... args){
System.out.println("hello java4");
}
};
33
Valid java main method
signature
public static void main(String[] args)
public static void main(String []args)
public static void main(String args[])
public static void main(String... args)
static public void main(String[] args)
public static final void main(String[] args)
final public static void main(String[] args)
34
35
36
2) How to set the Permanent Path of JDK in
Windows
Go to MyComputer properties -> advanced tab ->
environment variables -> new tab of user variable
-> write path in variable name -> write path of bin
folder in variable
value -> ok -> ok -> ok
37
JVM
JVM (Java Virtual Machine) is an abstract machine.
39
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.
The implementation of JVM is also actively released by other companies
besides Sun Micro Systems.
40
JDK
JDK is an acronym for Java Development Kit.
It is a software development environment which is used to develop
Java applications and applets.
It physically exists. It contains JRE + development tools.
The JDK contains a private Java Virtual Machine (JVM) and a few other
resources such as an interpreter/loader (java), a compiler (javac), an
archiver (jar), a documentation generator (Javadoc), etc. to complete
the development of a Java Application.
JDK is an implementation of any one of the below given Java
Platforms released by Oracle Corporation:
Standard Edition Java Platform
Enterprise Edition Java Platform
Micro Edition Java Platform
41
Difference between JVM, JRE, and JDK
JVMs are available for many hardware and software
platforms.
JVM, JRE, and JDK are platform dependent because
42
JRE, JDK & JVM
43
Thank you
44