SlideShare a Scribd company logo
Getting Started
What is Java?
• A programming language
– Fully buzzword-compliant:
A simple, object oriented, distributed, interpreted,
robust, secure, architecture neutral, portable, high
performance, multithreaded, dynamic language.
From: Java: An Overview
James Gosling, Sun Microsystems,
February 1995.
What Else is Java?
• According to Gosling:
– “An environment”
– “A platform”
– “A way of thinking”
– …ok, whatever
• Java is a phenomenon
– Took the world by storm in 1995 when
introduced with the HotJava web Browser
– Quickly integrated with Netscape browser
Some History
• 1993 Oak project at Sun
– small, robust, architecture independent, Object-Oriented,
language to control interactive TV.
– didn’t go anywhere
• 1995 Oak becomes Java
– Focus on the web
• 1996 Java 1.0 available
• 1997 (March) Java 1.1 - some language changes, much larger
library, new event handling model
• 1997 (September) Java 1.2 beta – huge increase in libraries
including Swing, new collection classes, J2EE
• 1998 (October) Java 1.2 final (Java2!)
• 2000 (April) Java 1.3 final
• 2001 Java 1.4 final (assert)
• 2004 Java 1.5 (parameterized types, enum, …) (Java5!)
• 2005 J2EE 1.5
What is Java?
• Java is a general-purpose, high-level
programming language.
– The features of Java
• Java program is both compiled and interpreted.
• Write once, run anywhere
• Java is a software-only platform running
on top of other, hardware-based platforms.
– Java Virtual Machine (Java VM)
– The Java Application Programming Interface
(JAVA API)
Features of Java
• Simple
• Architecture-neutral
• Object-Oriented
• Distributed
• Compiled
• Interpreted
• Statically Typed
• Multi-Threaded
• Garbage Collected
• Portable
• High-Performance
• Robust
• Secure
• Extensible
• Well-Understood
How Will Java Change My Life?
• Get started quickly
• Write less code
• Write better code
• Develop programs faster
• Avoid platform dependencies with 100%
pure Java
• Write once, run anywhere
• Distribute software more easily
Java Applications and Java … lets
• Stand-alone Applications
– Just like any programming language
• Applet
– Run under a Java-Enabled Browser
• Midlet
– Run in a Java-Enabled Mobile Phone
• Servlet
– Run on a Java-Enabled Web Server
• Switchlet
– …
Java Developer's Kit (I)
• Java's programming environment
– Core Java API
– compiler
– interpreter
– debugger
– dis-assembler
– profiler
– more...
Java Developer's Kit (II)
Java
Compiler
Java
Interpreter
Java Source Java Bytecode
Compile
Run
<file>.java <file>.class
Java
Dis-assembler
Prepare and Execute Java
Source Computer
Java Program Compilation Java ByteCode
Your computer
Java ByteCode Execution Restricted Env.
Verification
Internet
Write Once, Run Anywhere
ByteCode: Food for the VM
• For most languages, compilation
produces machine code
• Java compilation produces “bytecode”
– Intermediate code readable by the VM
– Transferable across the Internet as applets
• VM interprets BC into instructions
– Partly responsible for performance lag
• ByteCode produced on any platform
may be executed on any other platform
which supports a VM
virtual machine
execution model of Java
source
(text) compiler
CPU
bytecode
interpreter
bytecode
interpreter
dynamic
loading
JIT
compiler
JIT
compiler
compiled
code
compiled
code
JVML
verifier
bytecode
(aka. class file)
The JIT
• Just-In-Time compiler
• Translates bytecode into machine code
at runtime
– 1-time overhead when run initiated
– Performance increase 10-30 times
• Now the default for most JVM’s
– Can be turned off if desired
– JIT can apply statistical optimizations
based on runtime usage profile
Not just one JVM, but a whole
family
• JVM (J2EE & J2SE)
– Well-known Java Virtual Machine.
• CVM, KVM (J2ME)
– Small devices.
– Reduces some VM features to fit resource-
constrained devices.
• JCVM (Java Card)
– Smart cards.
– It has least VM features.
• And there are also lots of other JVMs
Java Platform & VM & Devices
Java VM and API
• Java API and Virtual
Machine insulate the
Java program from
hardware
dependencies.
• Java API
Java API
• Collection of ready-
made software
components that
provide many useful
capabilities.
• Grouped into libraries
(packages) of related
components.
• Core API
– Essentials: Object,
String, Input and
Output...
– Applets
– Networking
– Internationalization
– Security
– Software Components
– Object Serialization
– Java Database
Connectivity (JDBC)
The “Hello World” Application
Create a Java Source File
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Compile and Run
• Compile
– javac HelloWorld.java
• One file named HelloWorld.class is
created if the compilation is succeeds.
• Run
– java HelloWorld
The Simplest Java Application:
Hello,World!
• Since Java is object-oriented, programs are organized into modules
called classes, which may have data in variables and subroutines
called methods.
class HelloWorld
{ public static void main (String[] args)
{ System.out.println(“Hello World!”);
}
}
Each program is enclosed in a class definition.Each program is enclosed in a class definition.
main() is the first method that is run.main() is the first method that is run.
The notation class.method orThe notation class.method or
package.class.method is how topackage.class.method is how to
refer to a public method (withrefer to a public method (with
some exceptions).some exceptions).
Syntax is similar to C - braces forSyntax is similar to C - braces for
blocks, semicolon after eachblocks, semicolon after each
statement. One difference: upperstatement. One difference: upper
and lower case matter!and lower case matter!
The “Hello World” Applet
Create a Java Source File
HelloWorldApplet.java
• import java.applet.Applet;
import java.awt.Graphics;
public class HelloWorldApplet extends
Applet {
public void paint(Graphics g) {
g.drawString(“Hello World!”, 5, 25);
}
}
Compile the Source File
• javac HelloWorldApplet.java
• One file named HelloWorldApplet.class is
created if the compilation is succeeds.
Displaying your applet from a Web page.
• Create an HTML file with an applet tag to display the results of
drawing the applet.
<html><head>
<title>Simple Hello Page</title>
</head>
<body>
My Java applet says:
<applet code=“HelloWorldApplet.class” width=150 height=25>
</applet>
</body></html>
Name of your applet class.
The browser will use a rectangle of width 150 pixels andThe browser will use a rectangle of width 150 pixels and
height 25 pixels to display the applet within the other html.height 25 pixels to display the applet within the other html.
The Simplest Java Applet: Hello, World!
• Java applets are part of the class hierarchy that can call methods to
display on a screen (within the browser window). One way to draw on
the screen is to call the method drawString from the standard method
paint.
import java.awt.Graphics;
public class HelloWorldApplet extends java.applet.Applet
{ public void paint (Graphics g)
{ g.drawString(“Hello World!”, 5, 25);
}
}
The import statement allows the use of methodsThe import statement allows the use of methods
from the Graphics class without the dot notation .from the Graphics class without the dot notation .
The paint method displays a graphics object on theThe paint method displays a graphics object on the
screen - one of the standard methods that takes thescreen - one of the standard methods that takes the
place of main for applets.place of main for applets.
Puts this as a subclass of Applet.Puts this as a subclass of Applet.
No main method
• Yes, applets have a main method...
• ...but it's in the browser, not in your code!
• More about that later in the course …

More Related Content

PPTX
1 java introduction
PDF
Introduction To Core Java - SpringPeople
PDF
From Java to Ruby...and Back
PDF
Laravel - The PHP Framework for Web Artisans
PPT
PALASH SL GUPTA
PDF
Laravel and CodeIgniter: pros & cons
PPT
Advanced java
 
PDF
Laravel Introduction
1 java introduction
Introduction To Core Java - SpringPeople
From Java to Ruby...and Back
Laravel - The PHP Framework for Web Artisans
PALASH SL GUPTA
Laravel and CodeIgniter: pros & cons
Advanced java
 
Laravel Introduction

What's hot (19)

PPTX
Laravel introduction
PDF
Laravel
PPTX
Hire laravel-php-developers- Hire Laravel Programmers
PPTX
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
PDF
Social Connections 2015 CrossWorlds and Domino
PPTX
Laravel Tutorial PPT
PPTX
Getting started with laravel
ODP
Projects In Laravel : Learn Laravel Building 10 Projects
PPTX
Advanced JAVA
PPTX
Laravel overview
PPT
Basic javaprogramming(session1)
PDF
Georgia Tech Drupal Users Group - Local Drupal Development
PPTX
Java script nirvana in netbeans [con5679]
PPTX
PROGRAMMING IN JAVA- unit 5-part II
PDF
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
PDF
Java 8 in Anger (JavaOne)
PPTX
Developing in the Cloud
PPTX
Using Apache Camel as AKKA
PPTX
Introduction to Node (15th May 2017)
Laravel introduction
Laravel
Hire laravel-php-developers- Hire Laravel Programmers
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Social Connections 2015 CrossWorlds and Domino
Laravel Tutorial PPT
Getting started with laravel
Projects In Laravel : Learn Laravel Building 10 Projects
Advanced JAVA
Laravel overview
Basic javaprogramming(session1)
Georgia Tech Drupal Users Group - Local Drupal Development
Java script nirvana in netbeans [con5679]
PROGRAMMING IN JAVA- unit 5-part II
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
Java 8 in Anger (JavaOne)
Developing in the Cloud
Using Apache Camel as AKKA
Introduction to Node (15th May 2017)
Ad

Similar to Java1 (20)

PPT
Java1 in mumbai
PPTX
basic core java up to operator
PDF
Java Programming Fundamentals: Complete Guide for Beginners
PPTX
Introduction to java
PPT
JavaClassPresentation
PPTX
PPTX
JAVA PROGRAMING NOTE FOR BEGINNERS 20242
PDF
Introduction to Java Programming.pdf
PPT
Introduction to Core Java feature and its characteristics
PPTX
MWLUG - Universal Java
PDF
Java Programming
PPTX
1 java programming- introduction
PDF
Bn1005 demo ppt core java
PPTX
1.Intro--Why Java.pptx
PPTX
Java Programming Tutorials Basic to Advanced 1
PPTX
OOP-JAVA-UNIT-1-PPT updated.pptx object oriented programming language using java
PPTX
Object Oriented concept-JAVA-Module-1-PPT.pptx
PPTX
JAVA ALL 5 MODULE NOTES.pptx
PPT
j-chap1-Basics.ppt
PPTX
Java1 in mumbai
basic core java up to operator
Java Programming Fundamentals: Complete Guide for Beginners
Introduction to java
JavaClassPresentation
JAVA PROGRAMING NOTE FOR BEGINNERS 20242
Introduction to Java Programming.pdf
Introduction to Core Java feature and its characteristics
MWLUG - Universal Java
Java Programming
1 java programming- introduction
Bn1005 demo ppt core java
1.Intro--Why Java.pptx
Java Programming Tutorials Basic to Advanced 1
OOP-JAVA-UNIT-1-PPT updated.pptx object oriented programming language using java
Object Oriented concept-JAVA-Module-1-PPT.pptx
JAVA ALL 5 MODULE NOTES.pptx
j-chap1-Basics.ppt
Ad

Recently uploaded (20)

PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
DOCX
573137875-Attendance-Management-System-original
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Digital Logic Computer Design lecture notes
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
UNIT 4 Total Quality Management .pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
web development for engineering and engineering
PPTX
Geodesy 1.pptx...............................................
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
573137875-Attendance-Management-System-original
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Digital Logic Computer Design lecture notes
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
CH1 Production IntroductoryConcepts.pptx
CYBER-CRIMES AND SECURITY A guide to understanding
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Lecture Notes Electrical Wiring System Components
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
bas. eng. economics group 4 presentation 1.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
UNIT 4 Total Quality Management .pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
web development for engineering and engineering
Geodesy 1.pptx...............................................
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf

Java1

  • 2. What is Java? • A programming language – Fully buzzword-compliant: A simple, object oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high performance, multithreaded, dynamic language. From: Java: An Overview James Gosling, Sun Microsystems, February 1995.
  • 3. What Else is Java? • According to Gosling: – “An environment” – “A platform” – “A way of thinking” – …ok, whatever • Java is a phenomenon – Took the world by storm in 1995 when introduced with the HotJava web Browser – Quickly integrated with Netscape browser
  • 4. Some History • 1993 Oak project at Sun – small, robust, architecture independent, Object-Oriented, language to control interactive TV. – didn’t go anywhere • 1995 Oak becomes Java – Focus on the web • 1996 Java 1.0 available • 1997 (March) Java 1.1 - some language changes, much larger library, new event handling model • 1997 (September) Java 1.2 beta – huge increase in libraries including Swing, new collection classes, J2EE • 1998 (October) Java 1.2 final (Java2!) • 2000 (April) Java 1.3 final • 2001 Java 1.4 final (assert) • 2004 Java 1.5 (parameterized types, enum, …) (Java5!) • 2005 J2EE 1.5
  • 5. What is Java? • Java is a general-purpose, high-level programming language. – The features of Java • Java program is both compiled and interpreted. • Write once, run anywhere • Java is a software-only platform running on top of other, hardware-based platforms. – Java Virtual Machine (Java VM) – The Java Application Programming Interface (JAVA API)
  • 6. Features of Java • Simple • Architecture-neutral • Object-Oriented • Distributed • Compiled • Interpreted • Statically Typed • Multi-Threaded • Garbage Collected • Portable • High-Performance • Robust • Secure • Extensible • Well-Understood
  • 7. How Will Java Change My Life? • Get started quickly • Write less code • Write better code • Develop programs faster • Avoid platform dependencies with 100% pure Java • Write once, run anywhere • Distribute software more easily
  • 8. Java Applications and Java … lets • Stand-alone Applications – Just like any programming language • Applet – Run under a Java-Enabled Browser • Midlet – Run in a Java-Enabled Mobile Phone • Servlet – Run on a Java-Enabled Web Server • Switchlet – …
  • 9. Java Developer's Kit (I) • Java's programming environment – Core Java API – compiler – interpreter – debugger – dis-assembler – profiler – more...
  • 10. Java Developer's Kit (II) Java Compiler Java Interpreter Java Source Java Bytecode Compile Run <file>.java <file>.class Java Dis-assembler
  • 11. Prepare and Execute Java Source Computer Java Program Compilation Java ByteCode Your computer Java ByteCode Execution Restricted Env. Verification Internet
  • 12. Write Once, Run Anywhere
  • 13. ByteCode: Food for the VM • For most languages, compilation produces machine code • Java compilation produces “bytecode” – Intermediate code readable by the VM – Transferable across the Internet as applets • VM interprets BC into instructions – Partly responsible for performance lag • ByteCode produced on any platform may be executed on any other platform which supports a VM
  • 14. virtual machine execution model of Java source (text) compiler CPU bytecode interpreter bytecode interpreter dynamic loading JIT compiler JIT compiler compiled code compiled code JVML verifier bytecode (aka. class file)
  • 15. The JIT • Just-In-Time compiler • Translates bytecode into machine code at runtime – 1-time overhead when run initiated – Performance increase 10-30 times • Now the default for most JVM’s – Can be turned off if desired – JIT can apply statistical optimizations based on runtime usage profile
  • 16. Not just one JVM, but a whole family • JVM (J2EE & J2SE) – Well-known Java Virtual Machine. • CVM, KVM (J2ME) – Small devices. – Reduces some VM features to fit resource- constrained devices. • JCVM (Java Card) – Smart cards. – It has least VM features. • And there are also lots of other JVMs
  • 17. Java Platform & VM & Devices
  • 18. Java VM and API • Java API and Virtual Machine insulate the Java program from hardware dependencies. • Java API
  • 19. Java API • Collection of ready- made software components that provide many useful capabilities. • Grouped into libraries (packages) of related components. • Core API – Essentials: Object, String, Input and Output... – Applets – Networking – Internationalization – Security – Software Components – Object Serialization – Java Database Connectivity (JDBC)
  • 20. The “Hello World” Application
  • 21. Create a Java Source File public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } }
  • 22. Compile and Run • Compile – javac HelloWorld.java • One file named HelloWorld.class is created if the compilation is succeeds. • Run – java HelloWorld
  • 23. The Simplest Java Application: Hello,World! • Since Java is object-oriented, programs are organized into modules called classes, which may have data in variables and subroutines called methods. class HelloWorld { public static void main (String[] args) { System.out.println(“Hello World!”); } } Each program is enclosed in a class definition.Each program is enclosed in a class definition. main() is the first method that is run.main() is the first method that is run. The notation class.method orThe notation class.method or package.class.method is how topackage.class.method is how to refer to a public method (withrefer to a public method (with some exceptions).some exceptions). Syntax is similar to C - braces forSyntax is similar to C - braces for blocks, semicolon after eachblocks, semicolon after each statement. One difference: upperstatement. One difference: upper and lower case matter!and lower case matter!
  • 25. Create a Java Source File HelloWorldApplet.java • import java.applet.Applet; import java.awt.Graphics; public class HelloWorldApplet extends Applet { public void paint(Graphics g) { g.drawString(“Hello World!”, 5, 25); } }
  • 26. Compile the Source File • javac HelloWorldApplet.java • One file named HelloWorldApplet.class is created if the compilation is succeeds.
  • 27. Displaying your applet from a Web page. • Create an HTML file with an applet tag to display the results of drawing the applet. <html><head> <title>Simple Hello Page</title> </head> <body> My Java applet says: <applet code=“HelloWorldApplet.class” width=150 height=25> </applet> </body></html> Name of your applet class. The browser will use a rectangle of width 150 pixels andThe browser will use a rectangle of width 150 pixels and height 25 pixels to display the applet within the other html.height 25 pixels to display the applet within the other html.
  • 28. The Simplest Java Applet: Hello, World! • Java applets are part of the class hierarchy that can call methods to display on a screen (within the browser window). One way to draw on the screen is to call the method drawString from the standard method paint. import java.awt.Graphics; public class HelloWorldApplet extends java.applet.Applet { public void paint (Graphics g) { g.drawString(“Hello World!”, 5, 25); } } The import statement allows the use of methodsThe import statement allows the use of methods from the Graphics class without the dot notation .from the Graphics class without the dot notation . The paint method displays a graphics object on theThe paint method displays a graphics object on the screen - one of the standard methods that takes thescreen - one of the standard methods that takes the place of main for applets.place of main for applets. Puts this as a subclass of Applet.Puts this as a subclass of Applet.
  • 29. No main method • Yes, applets have a main method... • ...but it's in the browser, not in your code! • More about that later in the course …