KEMBAR78
Java Programming : introduction | PPT
1
JAVA PROGRAMMING
By
Dr.T.Abirami
Associate Professor
Department of IT
Kongu Engineering College Perundurai
2/3/2021
2
Introduction
2/3/2021
Author ,Year and Company
 Started in 1995 by SUN Microsystems
 James gosling, Arthur Van hoff, Andy
bechtolsheim
3
James Gosling
Oak is a symbol of strength
2/3/2021
Java Indroduction
 It is programming language
 It is class based and object oriented
programming language
 It is a platform independent language
 Java is both compiler and interpreter
language
 Java follows a bottom-up approach
4
2/3/2021
Real-World Java Applications
 Desktop GUI Applications
 Android Apps
 Web Applications
 Software Tools
 Trading Application
 J2ME Apps
 Embedded Space
 Big Data technologies
 Scientific Applications
5
2/3/2021
Example
 Banking: To deal with transaction management.
 Retail: Billing applications that you see in a
store/restaurant are completely written in Java.
 Information Technology: Java is designed to solve
implementation dependencies.
 Android: Applications are either written in Java or use Java
API.
 Financial services: It is used in server-side applications.
 Stock market: To write algorithms as to which company
they should invest in.
 Big Data: Hadoop MapReduce framework is written using
Java.
 Scientific and Research Community: To deal with huge
amount of data.
6
2/3/2021
Application
 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.
7
2/3/2021
Where it is used?
 1. Google's (Gmail & Youtube) is built
on Java/some other lang.
2. Twitter (Netty) & Linkedin uses Java
& Scala.
3. Amazon, Ebay, Blogger uses almost
Java.
8
2/3/2021
Types of Java Applications
 1) Standalone Application
 2) Web Application
 3) Enterprise Application
 4) Mobile Application
9
2/3/2021
Java Editions
 1) Java SE (Java Standard Edition) - It is a
Java programming platform.
 2) Java EE (Java Enterprise Edition) - It is an
enterprise platform which is mainly used to develop web and
enterprise applications.
 3) Java ME (Java Micro Edition) - to develop
mobile applications.
 4) JavaFX-to develop rich internet applications.
10
2/3/2021
Popular companies
 Uber
 Airbnb
 Google
 Pinterest
 Netflix
 Spotify
 Amazon
 Slack
 Instagram, etc.
11
2/3/2021
Java Version History
 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 Mar 2014)
 Java SE 9 (21st Sep 2017)
 Java SE 10 (20th Mar 2018)
 Java SE 11 and 14 ,15
12
2/3/2021
A Step By Step Guide To How To
Setup Eclipse IDE On Windows?
 Install Java
 Setup Eclipse IDE on Windows
 Hello World Program
13
2/3/2021
How to Download and Install
Eclipse to Run Java
 Step 1: Go to the Java Downloads Page and click
on the option of Download.
https://www.oracle.com/in/java/technologies/jav
ase-downloads.html
 2. Setup path
14
2/3/2021
Set the path for Java(JDK)
 Step 2: Once the installation is over
follow the below instructions to set the
path of the file.
 Go to start and search for ‘System’. Then,
click on ‘System’ and go to Advanced
System Settings. Refer below.
15
2/3/2021
Now, click on ‘Environment Variables’
under ‘Advanced’ tab as shown below:
16
2/3/2021
Install Eclipse:
https://www.eclipse.org/downloads/packag
es/release/Neon/2
17
2/3/2021
JDK, JRE, and JVM
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.
 It can also run those programs which are written
in other languages and compiled to Java
bytecode.
18
2/3/2021
The JVM performs the following
main tasks:
 Loads code
 Verifies code
 Executes code
 Provides runtime environment
19
Execution Engine :It contains:
• A virtual processor
• Interpreter: Read bytecode stream then execute the instructions.
• Just-In-Time(JIT) compiler:
•It is used to improve the performance.
•JIT compiles parts of the byte code that have similar functionality at the same time,
and hence reduces the amount of time needed for compilation.
• Here, the term "compiler" refers to a translator from the instruction set of a Java
virtual machine (JVM) to the instruction set of a specific CPU.
2/3/2021
JRE
 JRE is an acronym for Java Runtime Environment.
 It is also written as Java RTE.
 It 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.
20
2/3/2021
JDK(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.
21
2/3/2021
Learning Objectives
 To learn why Java is useful for the design of desktop , web and mobile
applications.
 To learn how to implement object-oriented designs with Java.
 To identify Java language components and how they work together in
applications.
 To design and program stand-alone Java applications.
 To learn how to design a graphical user interface (GUI) with Java AWT.
 To learn how to extend Java classes with inheritance and dynamic binding.
 To learn how to use exception handling in Java applications.
 To learn Java generics and how to use the Java Collections API.
 To understand how to design applications with threads in Java.
 To learn how to read and write files in Java.
22
2/3/2021
18ITO03 - JAVA
PROGRAMMING
23
2/3/2021
24
2/3/2021
LABORATORY
25
2/3/2021
26
First Program
public class HelloWorld {
public static void main(String args[])
{
System.out.println("Hello World");
}
}
2/3/2021
27
Compiling and Running
HelloWorld.java
javac HelloWorld.java
java HelloWorld HelloWorld.class
compile
run
bytecode
source code
2/3/2021
Why is JAVA a platform independent
language?
28
platform is the computer and the operating system running on it. The operating system can be
Windows, Mac, Linux, or any of many others It provides the environment to run the program
2/3/2021
Compiled Programs With Different
Operating Systems
Windows
compiler
Executable (Windows)
UNIX
compiler
Executable (UNIX)
Mac OS
compiler
Executable (Mac)
Computer
program
29
2/3/2021
A High Level View Of
Translating/Executing Java Programs
Java compiler
(javac)
Java program
Filename.java
Java
bytecode
(generic
binary)
Filename.class
Stage 1:
Compilation
30
2/3/2021
A High Level View Of
Translating/Executing Java Programs (2)
Java
interpreter
(java)
Java
bytecode
(generic
binary)
Filename.class
Machine language
instruction (UNIX)
Machine language
instruction
(Windows)
Machine language
instruction (Apple)
Stage 2: Interpreting and executing the
byte code
31
2/3/2021
Creating, Compiling And Running Java
Programs On The Computer Science
Network
javac
Java compiler
Java byte
code
filename.class
(UNIX file)
To compile the program
at the command line type
"javac filename.java"
To run the interpreter,
at the command line
type "java filename"
java
Java
Interpreter
Type it in with the text editor of
your choice
filename.java
(Unix file)
Java
program
32
2/3/2021
Compiling The Smallest Java Program
public class Smallest
{
public static void main (String[] args)
{
}
}
Smallest.java
javac
(Java byte code)
10000100000001000
00100100000001001
: :
Smallest.class
Type “javac
Smallest.java”
33
2/3/2021
Running The Smallest Java Program
(Java byte code)
10000100000001000
00100100000001001
: :
Smallest.class
java
Type “java
Smallest”
(Platform/Operating specific binary
10100111000001000
00100111001111001
: :
34
2/3/2021
35
Notice:
 Java is CASE SENSITIVE!!
 File name has to be the same as class
name in file.
 Need to import necessary class definitions
2/3/2021

Java Programming : introduction

  • 1.
    1 JAVA PROGRAMMING By Dr.T.Abirami Associate Professor Departmentof IT Kongu Engineering College Perundurai 2/3/2021
  • 2.
  • 3.
    Author ,Year andCompany  Started in 1995 by SUN Microsystems  James gosling, Arthur Van hoff, Andy bechtolsheim 3 James Gosling Oak is a symbol of strength 2/3/2021
  • 4.
    Java Indroduction  Itis programming language  It is class based and object oriented programming language  It is a platform independent language  Java is both compiler and interpreter language  Java follows a bottom-up approach 4 2/3/2021
  • 5.
    Real-World Java Applications Desktop GUI Applications  Android Apps  Web Applications  Software Tools  Trading Application  J2ME Apps  Embedded Space  Big Data technologies  Scientific Applications 5 2/3/2021
  • 6.
    Example  Banking: Todeal with transaction management.  Retail: Billing applications that you see in a store/restaurant are completely written in Java.  Information Technology: Java is designed to solve implementation dependencies.  Android: Applications are either written in Java or use Java API.  Financial services: It is used in server-side applications.  Stock market: To write algorithms as to which company they should invest in.  Big Data: Hadoop MapReduce framework is written using Java.  Scientific and Research Community: To deal with huge amount of data. 6 2/3/2021
  • 7.
    Application  Desktop Applicationssuch as acrobat reader, media player, antivirus, etc.  Web Applications  Enterprise Applications such as banking applications.  Mobile  Embedded System  Smart Card  Robotics  Games, etc. 7 2/3/2021
  • 8.
    Where it isused?  1. Google's (Gmail & Youtube) is built on Java/some other lang. 2. Twitter (Netty) & Linkedin uses Java & Scala. 3. Amazon, Ebay, Blogger uses almost Java. 8 2/3/2021
  • 9.
    Types of JavaApplications  1) Standalone Application  2) Web Application  3) Enterprise Application  4) Mobile Application 9 2/3/2021
  • 10.
    Java Editions  1)Java SE (Java Standard Edition) - It is a Java programming platform.  2) Java EE (Java Enterprise Edition) - It is an enterprise platform which is mainly used to develop web and enterprise applications.  3) Java ME (Java Micro Edition) - to develop mobile applications.  4) JavaFX-to develop rich internet applications. 10 2/3/2021
  • 11.
    Popular companies  Uber Airbnb  Google  Pinterest  Netflix  Spotify  Amazon  Slack  Instagram, etc. 11 2/3/2021
  • 12.
    Java Version History 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 Mar 2014)  Java SE 9 (21st Sep 2017)  Java SE 10 (20th Mar 2018)  Java SE 11 and 14 ,15 12 2/3/2021
  • 13.
    A Step ByStep Guide To How To Setup Eclipse IDE On Windows?  Install Java  Setup Eclipse IDE on Windows  Hello World Program 13 2/3/2021
  • 14.
    How to Downloadand Install Eclipse to Run Java  Step 1: Go to the Java Downloads Page and click on the option of Download. https://www.oracle.com/in/java/technologies/jav ase-downloads.html  2. Setup path 14 2/3/2021
  • 15.
    Set the pathfor Java(JDK)  Step 2: Once the installation is over follow the below instructions to set the path of the file.  Go to start and search for ‘System’. Then, click on ‘System’ and go to Advanced System Settings. Refer below. 15 2/3/2021
  • 16.
    Now, click on‘Environment Variables’ under ‘Advanced’ tab as shown below: 16 2/3/2021
  • 17.
  • 18.
    JDK, JRE, andJVM 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.  It can also run those programs which are written in other languages and compiled to Java bytecode. 18 2/3/2021
  • 19.
    The JVM performsthe following main tasks:  Loads code  Verifies code  Executes code  Provides runtime environment 19 Execution Engine :It contains: • A virtual processor • Interpreter: Read bytecode stream then execute the instructions. • Just-In-Time(JIT) compiler: •It is used to improve the performance. •JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation. • Here, the term "compiler" refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU. 2/3/2021
  • 20.
    JRE  JRE isan acronym for Java Runtime Environment.  It is also written as Java RTE.  It 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. 20 2/3/2021
  • 21.
    JDK(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. 21 2/3/2021
  • 22.
    Learning Objectives  Tolearn why Java is useful for the design of desktop , web and mobile applications.  To learn how to implement object-oriented designs with Java.  To identify Java language components and how they work together in applications.  To design and program stand-alone Java applications.  To learn how to design a graphical user interface (GUI) with Java AWT.  To learn how to extend Java classes with inheritance and dynamic binding.  To learn how to use exception handling in Java applications.  To learn Java generics and how to use the Java Collections API.  To understand how to design applications with threads in Java.  To learn how to read and write files in Java. 22 2/3/2021
  • 23.
  • 24.
  • 25.
  • 26.
    26 First Program public classHelloWorld { public static void main(String args[]) { System.out.println("Hello World"); } } 2/3/2021
  • 27.
    27 Compiling and Running HelloWorld.java javacHelloWorld.java java HelloWorld HelloWorld.class compile run bytecode source code 2/3/2021
  • 28.
    Why is JAVAa platform independent language? 28 platform is the computer and the operating system running on it. The operating system can be Windows, Mac, Linux, or any of many others It provides the environment to run the program 2/3/2021
  • 29.
    Compiled Programs WithDifferent Operating Systems Windows compiler Executable (Windows) UNIX compiler Executable (UNIX) Mac OS compiler Executable (Mac) Computer program 29 2/3/2021
  • 30.
    A High LevelView Of Translating/Executing Java Programs Java compiler (javac) Java program Filename.java Java bytecode (generic binary) Filename.class Stage 1: Compilation 30 2/3/2021
  • 31.
    A High LevelView Of Translating/Executing Java Programs (2) Java interpreter (java) Java bytecode (generic binary) Filename.class Machine language instruction (UNIX) Machine language instruction (Windows) Machine language instruction (Apple) Stage 2: Interpreting and executing the byte code 31 2/3/2021
  • 32.
    Creating, Compiling AndRunning Java Programs On The Computer Science Network javac Java compiler Java byte code filename.class (UNIX file) To compile the program at the command line type "javac filename.java" To run the interpreter, at the command line type "java filename" java Java Interpreter Type it in with the text editor of your choice filename.java (Unix file) Java program 32 2/3/2021
  • 33.
    Compiling The SmallestJava Program public class Smallest { public static void main (String[] args) { } } Smallest.java javac (Java byte code) 10000100000001000 00100100000001001 : : Smallest.class Type “javac Smallest.java” 33 2/3/2021
  • 34.
    Running The SmallestJava Program (Java byte code) 10000100000001000 00100100000001001 : : Smallest.class java Type “java Smallest” (Platform/Operating specific binary 10100111000001000 00100111001111001 : : 34 2/3/2021
  • 35.
    35 Notice:  Java isCASE SENSITIVE!!  File name has to be the same as class name in file.  Need to import necessary class definitions 2/3/2021