SlideShare ist ein Scribd-Unternehmen logo
1 von 29
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 …

Weitere ähnliche Inhalte

Was ist angesagt?

Laravel introduction
Laravel introductionLaravel introduction
Laravel introductionSimon Funk
 
Hire laravel-php-developers- Hire Laravel Programmers
Hire laravel-php-developers- Hire Laravel ProgrammersHire laravel-php-developers- Hire Laravel Programmers
Hire laravel-php-developers- Hire Laravel ProgrammersSummation IT
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Dilouar Hossain
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoPaul Withers
 
Projects In Laravel : Learn Laravel Building 10 Projects
Projects In Laravel : Learn Laravel Building 10 ProjectsProjects In Laravel : Learn Laravel Building 10 Projects
Projects In Laravel : Learn Laravel Building 10 ProjectsSam Dias
 
Basic javaprogramming(session1)
Basic javaprogramming(session1)Basic javaprogramming(session1)
Basic javaprogramming(session1)Barm Bannasan
 
Georgia Tech Drupal Users Group - Local Drupal Development
Georgia Tech Drupal Users Group - Local Drupal DevelopmentGeorgia Tech Drupal Users Group - Local Drupal Development
Georgia Tech Drupal Users Group - Local Drupal DevelopmentEric Sembrat
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Ryan Cuprak
 
PROGRAMMING IN JAVA- unit 5-part II
PROGRAMMING IN JAVA- unit 5-part IIPROGRAMMING IN JAVA- unit 5-part II
PROGRAMMING IN JAVA- unit 5-part IISivaSankari36
 
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010Arun Gupta
 
Java 8 in Anger (JavaOne)
Java 8 in Anger (JavaOne)Java 8 in Anger (JavaOne)
Java 8 in Anger (JavaOne)Trisha Gee
 
Developing in the Cloud
Developing in the CloudDeveloping in the Cloud
Developing in the CloudRyan Cuprak
 
Using Apache Camel as AKKA
Using Apache Camel as AKKAUsing Apache Camel as AKKA
Using Apache Camel as AKKAJohan Edstrom
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Lucas Jellema
 

Was ist angesagt? (19)

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

Ähnlich wie Java1

Ähnlich wie Java1 (20)

Java1 in mumbai
Java1 in mumbaiJava1 in mumbai
Java1 in mumbai
 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operator
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentation
 
1 java intro
1 java intro1 java intro
1 java intro
 
Introduction to Java Programming.pdf
Introduction to Java Programming.pdfIntroduction to Java Programming.pdf
Introduction to Java Programming.pdf
 
MWLUG - Universal Java
MWLUG  -  Universal JavaMWLUG  -  Universal Java
MWLUG - Universal Java
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
Bn1005 demo ppt core java
Bn1005 demo ppt core javaBn1005 demo ppt core java
Bn1005 demo ppt core java
 
1.Intro--Why Java.pptx
1.Intro--Why Java.pptx1.Intro--Why Java.pptx
1.Intro--Why Java.pptx
 
JAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxJAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptx
 
j-chap1-Basics.ppt
j-chap1-Basics.pptj-chap1-Basics.ppt
j-chap1-Basics.ppt
 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
 
Java introduction
Java introductionJava introduction
Java introduction
 
unit1.pptx
unit1.pptxunit1.pptx
unit1.pptx
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
 
Advance java prasentation
Advance java prasentationAdvance java prasentation
Advance java prasentation
 
JAVA INTRODUCTION - 1
JAVA INTRODUCTION - 1JAVA INTRODUCTION - 1
JAVA INTRODUCTION - 1
 
Intoduction to java
Intoduction to javaIntoduction to java
Intoduction to java
 

Kürzlich hochgeladen

IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 

Kürzlich hochgeladen (20)

IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 

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 …