SlideShare a Scribd company logo
1 of 53
Java I--Copyright © 2000-2004 Tom Hunter
Java I--Copyright © 2000-2004 Tom Hunter
Chapter 1
Introduction to Computers,
 the Internet and the Web




                    Java I--Copyright © 2000-2004 Tom Hunter
The Genesis of Java
• It all started with an angry programmer.
1990

Sun Microsystems Software
Engineer Patrick Naughton,
age 25, was disgusted with
his job at Sun. He had the impossible job of
making different software APIs--from
dozens of languages, platform OS’s and
vendors--all work as one. It was impossible.
                               Java I--Copyright © 2000-2004 Tom Hunter
The Genesis of Java
     Naughton announced to CEO
Scott McNealy that he was quitting Sun.
               Pat was going to join NeXT,
               because Sun was a mess.


     McNealy asked Pat to write a memo
outlining his gripes.
     The CEO asked Pat to suggest a
solution, “As if you were God.”
                              Java I--Copyright © 2000-2004 Tom Hunter
The Genesis of Java
• Formation of the “Green Project”
Jan 1991

      The array of standards spurred the
formation of the “Green Project.” Its goal
was making Consumer Electronics devices
talk to each other.
     Since VCRs, Laser Disc Players and
Stereos were all made with different CPUs,
they all needed special programming.
                               Java I--Copyright © 2000-2004 Tom Hunter
The Genesis of Java
• James Gosling, then age 36, was asked to find a
programming language for the project.
                Gosling, who had left
                IBM in 1984 to join Sun,
                first chose C++. But he
                soon gave up on C++,
                which was incapable of doing
                what he wanted. So, he started to
                       modify C++, (which is a
direct descendant of the C programming
language).
                                   Java I--Copyright © 2000-2004 Tom Hunter
The Genesis of Java
• Soon, Gosling was writing a new language,
which he named “Oak” after the tree outside
his window.
Oak to had to be:
     • Small to work on Consumer electronics,
     • Platform independent, to avoid hassles like the
            ones Naughton encountered,
     • an Interpreted language,
     • Object Oriented,



                                       Java I--Copyright © 2000-2004 Tom Hunter
The Genesis of Java
  • Reliable--which made him remove aspects of C++:
         i.) No Multiple Inheritance--he used interfaces
                        instead
         ii.) No Operator Overloading
         iii.) No Manual Memory allocation and dealloc
         iv.) No Pointers--no pointer arithmetic
         v.) No assignment in conditionals (== vs = )
  and add things C++ lacked:
         i.) Implicit Garbage Collection--no memory leaks
         ii.) Data Structures only in Objects
         iii.) Built in Security.

                                      Java I--Copyright © 2000-2004 Tom Hunter
The Genesis of Java
• Demo of *7, Programmed in Oak
3 Sept 1992

This was the prototype of the
first device to use the Oak
programming language.
           The “Star7” also featured the
           debut of “Duke,” the Java
           mascot. An early applet
           showed Duke doing cartwheels
across the screen.            Java I--Copyright © 2000-2004 Tom Hunter
The Genesis of Java
• Oak becomes Java.
Jan 1995

      By this time, the Internet had taken off.
Bill Joy, one of Sun’s founders, realized that
the needs of the Web [ reliability, platform
independence, security ] exactly matched the
characteristics of Oak, which had just been
renamed Java.

                                 Java I--Copyright © 2000-2004 Tom Hunter
The Genesis of Java
• Java Catches Fire
23 Mar 1995

      Although Java had not yet been
officially released, it was spreading like
wildfire among developers.
      Then, something very lucky happened...



                                 Java I--Copyright © 2000-2004 Tom Hunter
Java I--Copyright © 2000-2004 Tom Hunter
The Genesis of Java
•Netscape Navigator 2.0
23 May 1995

Two months later, at the SunWorld
conference, Marc Andreessen stepped on
stage and announced that “Java is real, and it
will be incorporated into Netscape Navigator
2.0.”
At this moment, Sun’s entire Java team only
numbered 30 people.
                                Java I--Copyright © 2000-2004 Tom Hunter
Java’s
Major Advantage
 over C & C++


             Java I--Copyright © 2000-2004 Tom Hunter
Java’s Major Advantage over C & C++

• Because pointers were a major source of
bugs in C and C++, Gosling omitted pointers
entirely from Java.

• Actually, pointers are still an important part
of the language--all objects are referenced by
pointers--but the language handles them, not
the programmer.

                                  Java I--Copyright © 2000-2004 Tom Hunter
Java’s Origins in C & C++

Thus, it has been said that...

“Java is C without
  the Guns and
    Knives.”
                                 Java I--Copyright © 2000-2004 Tom Hunter
Java Architecture
• By now, Java itself has matured into its 3rd
version, named Java 2. This course is based
on Java 2. The most current is Java 2 (1.5.1)
• Java is Object-Oriented--that means
everything in the language behaves like an
object.
• What exactly that means will be explained
in the coming weeks.
                                Java I--Copyright © 2000-2004 Tom Hunter
Java Architecture

     Java’s Architecture comes from four
separate but intertwined technologies:
     • the Java Programming Language
     • the Java class file format
     • the Java API, or Application Programming Interface
     • the Java Virtual Machine



                                        Java I--Copyright © 2000-2004 Tom Hunter
Java Architecture
Source programs are written in the Java
Programming Language.

All procedural code falls within methods.

Programs are compiled into Java class files.

Classes run in the Java Virtual Machine.


                                Java I--Copyright © 2000-2004 Tom Hunter
Java Architecture


        • When a Java program runs,
        it is assisted by other classes
        in the Java the Application
        Programming Interface, or
        API.




                                Java I--Copyright © 2000-2004 Tom Hunter
Java Architecture
 Combined, the Java     Example Java API class files
 Virtual Machine and
                 Object.class      String.class
 the Java API form a
     “Platform.”
   Compile-Time
   Environment
     Hello.class
                                                      Java
                                                     Virtual
       Java
     Compiler                                        Machine

                                                        Run-Time
    Hello.java                                         Environment
                    The Java PlatformJava I--Copyright © 2000-2004 Tom Hunter
Java Architecture


• The Java Platform is unique, because it can
work without modification               on
any platform,                      on any
operating system,             if that
platform has a                “Java Virtual
Machine.”



                               Java I--Copyright © 2000-2004 Tom Hunter
Java Architecture
                       Java
     What is the      Virtual             ?
                      Machine

Comparison of a typical Procedural
Program with a Java Program:
• In a typical C program, the source code is
compiled into a native machine language
module that consists of 1’s and 0’s.
                               Java I--Copyright © 2000-2004 Tom Hunter
C Source Code



           C object module
            compiled into
           machine language

• The machine language is specifically tailored
to one OS, be it Wintel, Mac, UNIX or MVS.
• Therefore, it is impossible for one object
module to be portable between platforms.
                                Java I--Copyright © 2000-2004 Tom Hunter
Java Architecture

         Java “bytecode”
In contrast to conventional programming
languages, a Java program is not compiled
into native machine language.
• Instead, Java makes bytecode.
• Bytecode is the result of a “compile”, but
the compile results in an intermediate form
that stops short of native machine-specific
code.                          Java I--Copyright © 2000-2004 Tom Hunter
Java Architecture

• Instead of making a machine language
native code for each particular OS, Java
makes a single, universal bytecode module
that feeds into any Java Virtual Machine
(JVM).

• Each OS has its own different
implementation of the
                    Java Virtual Machine.
                              Java I--Copyright © 2000-2004 Tom Hunter
Java Architecture

• The JVM sets up its own world within
your RAM.

• The JVM creates an internal
software-only sub-computer within the OS.

• The bytecode talks to the JVM, and the
JVM talks to the Operating System.

                              Java I--Copyright © 2000-2004 Tom Hunter
Java Architecture

• Thus, you get the Holy Grail of software reuse:



         “Write Once,
        Run Anywhere”.

                                 Java I--Copyright © 2000-2004 Tom Hunter
Java Source
              You can easily see why Bill
The            Gates isn’t in love with
bytecode       Java Bytecode
                         Java!
is met
half-way
by the
JVM.


JVM-Win       JVM-Mac    JVM-Unix             JVM-IBM
 Wintel        Mac        UNIX                    MVS
                               Java I--Copyright © 2000-2004 Tom Hunter
Java Architecture

  • The Virtual Machine interprets the
  bytecode one instruction at a time,
  and translates it into native machine
  code.

  • You compile your program once
  into bytecode, but it is interpreted
  anew every time it runs.

                                Java I--Copyright © 2000-2004 Tom Hunter
Security and the
  “Sandbox”



             Java I--Copyright © 2000-2004 Tom Hunter
Security and the “Sandbox”

     C and C++ are famous for speed.

     • One reason they are fast is because C
and C++ don’t do things like checking the
bounds of arrays.
     • In C or C++, a program can walk off
the edge of an array and invade the memory
space beyond.
     • Hackers love that about C and C++.
                                Java I--Copyright © 2000-2004 Tom Hunter
Security and the “Sandbox”
• Another weakness of C/C++, that is a
favorite among Hackers, is the Buffer
Overflow.

• In this attack, the Hacker floods too much
data into a buffer and whatever overflows it is
turned loose on the system.

• Java solves these problems

                                Java I--Copyright © 2000-2004 Tom Hunter
Security and the “Sandbox”

• How Java Combats malicious code:
    Java checks array boundaries
    Java halts Buffer Overflows
    Java has Garbage collection to get rid
          of objects that are no longer used.
    Java’s compiler checks to make sure
          the code is safe before it runs.
• Gosling built security into Java, using a
concept known as the “Sandbox.”
                               Java I--Copyright © 2000-2004 Tom Hunter
Security and the “Sandbox”                Remote Code
                   Local Code
       All Code, both Local and Remote, Must Pass Security
                              Policy
          JDK 1.2                 Security Model

                                         SANDBOX



                        Vulnerable System Resources
                     (files, etc) Even Local Code is Not
                                    Trusted

Has Fine-Grain Access Control                   Java I--Copyright © 2000-2004 Tom Hunter
Security and the “Sandbox”
• 5 Steps To Writing A Java Program:
     1.) Write it in a Text Editor
     2.) Compiler creates bytecode
     3.) The “Class loader” places the .class
          file in memory.
     4.) The “Bytecode Verifier” makes sure
          the code adheres to Java’s security
          rules.
     5.) The JVM Interpreter reads bytecode
          and makes platform native code.
                              Java I--Copyright © 2000-2004 Tom Hunter
Security and the “Sandbox”
• You see, preventing problems is a major
design consideration in Java.

• This idea led to the most import aspect of
Java: Object Orientation.

• Object Orientation protects data and lets a
program do only what is explicitly permitted.

• You could say Java is pessimistic.
                                Java I--Copyright © 2000-2004 Tom Hunter
Objects in Java

• In Java, Object Orientation is so
pervasive that it’s nearly impossible
to write a strictly procedural program
in the language.




                            Java I--Copyright © 2000-2004 Tom Hunter
Objects in Java

• Objects are reusable components.

• In Java, everything must be run from a
“class” file. This “class” contains bytecode.

• Java source code has the extension
Xxx.java


                                Java I--Copyright © 2000-2004 Tom Hunter
Objects in Java

• If I write a Java program called:

     Hello.java

     then, when compiled, this program will
be called:

     Hello.class


                                 Java I--Copyright © 2000-2004 Tom Hunter
Objects in Java
• A class object is compiled Java code that
contains its own data variables, called
members, and sections of procedural code
called methods.

    If you have programmed in COBOL, a
method is like a paragraph you perform.

    If you have programmed in C or C++, a
method is like a function your program calls.
                                Java I--Copyright © 2000-2004 Tom Hunter
Objects in Java

• The combination of the data variables
         and the methods
                   that are used to read,
                                    write
                               or modify
                         those variables

is called a class.


                               Java I--Copyright © 2000-2004 Tom Hunter
Objects in Java

• Java has a rich collection of Class Libraries.

• These are also known as the Java API or
Application Programming Interface.

• To program in Java, you must

     i.) Learn the Language, and
     ii.) Learn the Class Libraries.
                                 Java I--Copyright © 2000-2004 Tom Hunter
Objects in Java

• These class libraries greatly simplify your
job as a Java programmer.

• They help you to write complex programs
quickly.

• To master Java, you must master these
class libraries.


                                Java I--Copyright © 2000-2004 Tom Hunter
Compiling A Java Program
• You have created a Java program called
      Hello.java
• To compile it, you run the JDK supplied
utility called:
                javac
C:javac Hello.java
    If this was successful, a file called:
  Hello.class will be produced.
                                 Java I--Copyright © 2000-2004 Tom Hunter
First Java Program
• The two largest varieties of Java
programs:

     Applications

     Applets

                                Java I--Copyright © 2000-2004 Tom Hunter
First Java Program

• A Java Application is a free-standing
program that is capable of running
directly in the Java Virtual Machine.

• A Java Applet is a mini-program that is
much more limited in its abilities. An
Applet can only run within the context of
an HTML browser.

                               Java I--Copyright © 2000-2004 Tom Hunter
A Java Application
// HelloWorld.java Our first Java Application

public class HelloWorld
{
       public static void main( String args[])
       {
              System.out.println( “Hello World!” );
       }
}

Nowdouble slashesname. a “C++”-style comment.
The our Application is complete. We have added the
   This is the class denote
method “main”. All methodsJava lowerslashesmain is
   Every single bit of code in are must case. is
Everything on the line after the double sit in curly brackets.
a specialby the compiler.
ignored names are capitalized. the program.
   Class method--it actually runs
   Words within the name are also capitalized.
        In any application, you are always guaranteed
that method main will run.be saved in a file with the exact
   This Java program must
   same name--matching the upper case--as you see in blue
   above: HelloWorld.java
                                       Java I--Copyright © 2000-2004 Tom Hunter
A Java Application


  C:>javac HelloWorld.java

  C:>


• A successful compile of your java
program will return to a bare cursor, as
you see here.

                               Java I--Copyright © 2000-2004 Tom Hunter
A Java Application
  C:>javac HelloWorld.java

  C:>java HelloWorld
  Hello World!

     • To run your compiled Application,
you enter lowercase java HelloWorld
on the command line.
      • Notice, the “.class” extension is
omitted.
                             Java I--Copyright © 2000-2004 Tom Hunter
In Class Activity

Now load the JDK1.4.1,
the documentation,
change the class path and
write your first Java program.



                                 Java I--Copyright © 2000-2004 Tom Hunter
Java I--Copyright © 2000-2004 Tom Hunter

More Related Content

What's hot

Quickstart: Qt for Windows, Symbian and Maemo / Meego v2.0.8 (January 10th, 2...
Quickstart: Qt for Windows, Symbian and Maemo / Meego v2.0.8 (January 10th, 2...Quickstart: Qt for Windows, Symbian and Maemo / Meego v2.0.8 (January 10th, 2...
Quickstart: Qt for Windows, Symbian and Maemo / Meego v2.0.8 (January 10th, 2...Andreas Jakl
 
ITCamp 2011 - Alessandro Pilotti - Optimizing ASPNet and PHP apps on IIS 7.5
ITCamp 2011 - Alessandro Pilotti - Optimizing ASPNet and PHP apps on IIS 7.5ITCamp 2011 - Alessandro Pilotti - Optimizing ASPNet and PHP apps on IIS 7.5
ITCamp 2011 - Alessandro Pilotti - Optimizing ASPNet and PHP apps on IIS 7.5ITCamp
 
Forum Nokia Dev. Camp - WRT training Paris_17&18 Nov.
Forum Nokia Dev. Camp - WRT training Paris_17&18 Nov.Forum Nokia Dev. Camp - WRT training Paris_17&18 Nov.
Forum Nokia Dev. Camp - WRT training Paris_17&18 Nov.DALEZ
 
Create *real* modular Java applications - a brief introduction -
Create *real* modular Java applications - a brief introduction -Create *real* modular Java applications - a brief introduction -
Create *real* modular Java applications - a brief introduction -Jeffrey Groneberg
 
Android : How Do I Code Thee?
Android : How Do I Code Thee?Android : How Do I Code Thee?
Android : How Do I Code Thee?Viswanath J
 
The anatomy and philosophy of Android - Google I/O 2009
The anatomy and philosophy of Android - Google I/O 2009The anatomy and philosophy of Android - Google I/O 2009
The anatomy and philosophy of Android - Google I/O 2009Viswanath J
 

What's hot (10)

History of java
History of javaHistory of java
History of java
 
Quickstart: Qt for Windows, Symbian and Maemo / Meego v2.0.8 (January 10th, 2...
Quickstart: Qt for Windows, Symbian and Maemo / Meego v2.0.8 (January 10th, 2...Quickstart: Qt for Windows, Symbian and Maemo / Meego v2.0.8 (January 10th, 2...
Quickstart: Qt for Windows, Symbian and Maemo / Meego v2.0.8 (January 10th, 2...
 
History of Java 1/2
History of Java 1/2History of Java 1/2
History of Java 1/2
 
ITCamp 2011 - Alessandro Pilotti - Optimizing ASPNet and PHP apps on IIS 7.5
ITCamp 2011 - Alessandro Pilotti - Optimizing ASPNet and PHP apps on IIS 7.5ITCamp 2011 - Alessandro Pilotti - Optimizing ASPNet and PHP apps on IIS 7.5
ITCamp 2011 - Alessandro Pilotti - Optimizing ASPNet and PHP apps on IIS 7.5
 
Forum Nokia Dev. Camp - WRT training Paris_17&18 Nov.
Forum Nokia Dev. Camp - WRT training Paris_17&18 Nov.Forum Nokia Dev. Camp - WRT training Paris_17&18 Nov.
Forum Nokia Dev. Camp - WRT training Paris_17&18 Nov.
 
Software development with qt
Software development with qtSoftware development with qt
Software development with qt
 
Create *real* modular Java applications - a brief introduction -
Create *real* modular Java applications - a brief introduction -Create *real* modular Java applications - a brief introduction -
Create *real* modular Java applications - a brief introduction -
 
Hardware Accelerated 2D Rendering for Android
Hardware Accelerated 2D Rendering for AndroidHardware Accelerated 2D Rendering for Android
Hardware Accelerated 2D Rendering for Android
 
Android : How Do I Code Thee?
Android : How Do I Code Thee?Android : How Do I Code Thee?
Android : How Do I Code Thee?
 
The anatomy and philosophy of Android - Google I/O 2009
The anatomy and philosophy of Android - Google I/O 2009The anatomy and philosophy of Android - Google I/O 2009
The anatomy and philosophy of Android - Google I/O 2009
 

Viewers also liked

Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...
Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...
Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...Marakana Inc.
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMarakana Inc.
 
Why Java Needs Hierarchical Data
Why Java Needs Hierarchical DataWhy Java Needs Hierarchical Data
Why Java Needs Hierarchical DataMarakana Inc.
 
Android Services Black Magic by Aleksandar Gargenta
Android Services Black Magic by Aleksandar GargentaAndroid Services Black Magic by Aleksandar Gargenta
Android Services Black Magic by Aleksandar GargentaMarakana Inc.
 
Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven DevelopmentMarakana Inc.
 

Viewers also liked (6)

Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...
Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...
Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for Scala
 
JRuby at Square
JRuby at SquareJRuby at Square
JRuby at Square
 
Why Java Needs Hierarchical Data
Why Java Needs Hierarchical DataWhy Java Needs Hierarchical Data
Why Java Needs Hierarchical Data
 
Android Services Black Magic by Aleksandar Gargenta
Android Services Black Magic by Aleksandar GargentaAndroid Services Black Magic by Aleksandar Gargenta
Android Services Black Magic by Aleksandar Gargenta
 
Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven Development
 

Similar to Java i lecture_1_upd1

Similar to Java i lecture_1_upd1 (20)

intoduction to java
intoduction to javaintoduction to java
intoduction to java
 
Java hot spot
Java hot spotJava hot spot
Java hot spot
 
PPS Java Overview Unit I.ppt
PPS Java Overview Unit I.pptPPS Java Overview Unit I.ppt
PPS Java Overview Unit I.ppt
 
PPS Java Overview Unit I.ppt
PPS Java Overview Unit I.pptPPS Java Overview Unit I.ppt
PPS Java Overview Unit I.ppt
 
Java
JavaJava
Java
 
Chapter 1 java
Chapter 1 java Chapter 1 java
Chapter 1 java
 
Java Class1
Java Class1Java Class1
Java Class1
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentation
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operator
 
An introduction to java programming language forbeginners(java programming tu...
An introduction to java programming language forbeginners(java programming tu...An introduction to java programming language forbeginners(java programming tu...
An introduction to java programming language forbeginners(java programming tu...
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 
1 java introduction
1 java introduction1 java introduction
1 java introduction
 
1 java intro
1 java intro1 java intro
1 java intro
 
Lec 1-of-oop2
Lec 1-of-oop2Lec 1-of-oop2
Lec 1-of-oop2
 
Core java slides
Core java slidesCore java slides
Core java slides
 
Presentation on java
Presentation on javaPresentation on java
Presentation on java
 
J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01
 

Recently uploaded

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...marcuskenyatta275
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastUXDXConf
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIES VE
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessUXDXConf
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024Stephen Perrenod
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimaginedpanagenda
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftshyamraj55
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfFIDO Alliance
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FIDO Alliance
 

Recently uploaded (20)

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 

Java i lecture_1_upd1

  • 1. Java I--Copyright © 2000-2004 Tom Hunter
  • 2. Java I--Copyright © 2000-2004 Tom Hunter
  • 3. Chapter 1 Introduction to Computers, the Internet and the Web Java I--Copyright © 2000-2004 Tom Hunter
  • 4. The Genesis of Java • It all started with an angry programmer. 1990 Sun Microsystems Software Engineer Patrick Naughton, age 25, was disgusted with his job at Sun. He had the impossible job of making different software APIs--from dozens of languages, platform OS’s and vendors--all work as one. It was impossible. Java I--Copyright © 2000-2004 Tom Hunter
  • 5. The Genesis of Java Naughton announced to CEO Scott McNealy that he was quitting Sun. Pat was going to join NeXT, because Sun was a mess. McNealy asked Pat to write a memo outlining his gripes. The CEO asked Pat to suggest a solution, “As if you were God.” Java I--Copyright © 2000-2004 Tom Hunter
  • 6. The Genesis of Java • Formation of the “Green Project” Jan 1991 The array of standards spurred the formation of the “Green Project.” Its goal was making Consumer Electronics devices talk to each other. Since VCRs, Laser Disc Players and Stereos were all made with different CPUs, they all needed special programming. Java I--Copyright © 2000-2004 Tom Hunter
  • 7. The Genesis of Java • James Gosling, then age 36, was asked to find a programming language for the project. Gosling, who had left IBM in 1984 to join Sun, first chose C++. But he soon gave up on C++, which was incapable of doing what he wanted. So, he started to modify C++, (which is a direct descendant of the C programming language). Java I--Copyright © 2000-2004 Tom Hunter
  • 8. The Genesis of Java • Soon, Gosling was writing a new language, which he named “Oak” after the tree outside his window. Oak to had to be: • Small to work on Consumer electronics, • Platform independent, to avoid hassles like the ones Naughton encountered, • an Interpreted language, • Object Oriented, Java I--Copyright © 2000-2004 Tom Hunter
  • 9. The Genesis of Java • Reliable--which made him remove aspects of C++: i.) No Multiple Inheritance--he used interfaces instead ii.) No Operator Overloading iii.) No Manual Memory allocation and dealloc iv.) No Pointers--no pointer arithmetic v.) No assignment in conditionals (== vs = ) and add things C++ lacked: i.) Implicit Garbage Collection--no memory leaks ii.) Data Structures only in Objects iii.) Built in Security. Java I--Copyright © 2000-2004 Tom Hunter
  • 10. The Genesis of Java • Demo of *7, Programmed in Oak 3 Sept 1992 This was the prototype of the first device to use the Oak programming language. The “Star7” also featured the debut of “Duke,” the Java mascot. An early applet showed Duke doing cartwheels across the screen. Java I--Copyright © 2000-2004 Tom Hunter
  • 11. The Genesis of Java • Oak becomes Java. Jan 1995 By this time, the Internet had taken off. Bill Joy, one of Sun’s founders, realized that the needs of the Web [ reliability, platform independence, security ] exactly matched the characteristics of Oak, which had just been renamed Java. Java I--Copyright © 2000-2004 Tom Hunter
  • 12. The Genesis of Java • Java Catches Fire 23 Mar 1995 Although Java had not yet been officially released, it was spreading like wildfire among developers. Then, something very lucky happened... Java I--Copyright © 2000-2004 Tom Hunter
  • 13. Java I--Copyright © 2000-2004 Tom Hunter
  • 14. The Genesis of Java •Netscape Navigator 2.0 23 May 1995 Two months later, at the SunWorld conference, Marc Andreessen stepped on stage and announced that “Java is real, and it will be incorporated into Netscape Navigator 2.0.” At this moment, Sun’s entire Java team only numbered 30 people. Java I--Copyright © 2000-2004 Tom Hunter
  • 15. Java’s Major Advantage over C & C++ Java I--Copyright © 2000-2004 Tom Hunter
  • 16. Java’s Major Advantage over C & C++ • Because pointers were a major source of bugs in C and C++, Gosling omitted pointers entirely from Java. • Actually, pointers are still an important part of the language--all objects are referenced by pointers--but the language handles them, not the programmer. Java I--Copyright © 2000-2004 Tom Hunter
  • 17. Java’s Origins in C & C++ Thus, it has been said that... “Java is C without the Guns and Knives.” Java I--Copyright © 2000-2004 Tom Hunter
  • 18. Java Architecture • By now, Java itself has matured into its 3rd version, named Java 2. This course is based on Java 2. The most current is Java 2 (1.5.1) • Java is Object-Oriented--that means everything in the language behaves like an object. • What exactly that means will be explained in the coming weeks. Java I--Copyright © 2000-2004 Tom Hunter
  • 19. Java Architecture Java’s Architecture comes from four separate but intertwined technologies: • the Java Programming Language • the Java class file format • the Java API, or Application Programming Interface • the Java Virtual Machine Java I--Copyright © 2000-2004 Tom Hunter
  • 20. Java Architecture Source programs are written in the Java Programming Language. All procedural code falls within methods. Programs are compiled into Java class files. Classes run in the Java Virtual Machine. Java I--Copyright © 2000-2004 Tom Hunter
  • 21. Java Architecture • When a Java program runs, it is assisted by other classes in the Java the Application Programming Interface, or API. Java I--Copyright © 2000-2004 Tom Hunter
  • 22. Java Architecture Combined, the Java Example Java API class files Virtual Machine and Object.class String.class the Java API form a “Platform.” Compile-Time Environment Hello.class Java Virtual Java Compiler Machine Run-Time Hello.java Environment The Java PlatformJava I--Copyright © 2000-2004 Tom Hunter
  • 23. Java Architecture • The Java Platform is unique, because it can work without modification on any platform, on any operating system, if that platform has a “Java Virtual Machine.” Java I--Copyright © 2000-2004 Tom Hunter
  • 24. Java Architecture Java What is the Virtual ? Machine Comparison of a typical Procedural Program with a Java Program: • In a typical C program, the source code is compiled into a native machine language module that consists of 1’s and 0’s. Java I--Copyright © 2000-2004 Tom Hunter
  • 25. C Source Code C object module compiled into machine language • The machine language is specifically tailored to one OS, be it Wintel, Mac, UNIX or MVS. • Therefore, it is impossible for one object module to be portable between platforms. Java I--Copyright © 2000-2004 Tom Hunter
  • 26. Java Architecture Java “bytecode” In contrast to conventional programming languages, a Java program is not compiled into native machine language. • Instead, Java makes bytecode. • Bytecode is the result of a “compile”, but the compile results in an intermediate form that stops short of native machine-specific code. Java I--Copyright © 2000-2004 Tom Hunter
  • 27. Java Architecture • Instead of making a machine language native code for each particular OS, Java makes a single, universal bytecode module that feeds into any Java Virtual Machine (JVM). • Each OS has its own different implementation of the Java Virtual Machine. Java I--Copyright © 2000-2004 Tom Hunter
  • 28. Java Architecture • The JVM sets up its own world within your RAM. • The JVM creates an internal software-only sub-computer within the OS. • The bytecode talks to the JVM, and the JVM talks to the Operating System. Java I--Copyright © 2000-2004 Tom Hunter
  • 29. Java Architecture • Thus, you get the Holy Grail of software reuse: “Write Once, Run Anywhere”. Java I--Copyright © 2000-2004 Tom Hunter
  • 30. Java Source You can easily see why Bill The Gates isn’t in love with bytecode Java Bytecode Java! is met half-way by the JVM. JVM-Win JVM-Mac JVM-Unix JVM-IBM Wintel Mac UNIX MVS Java I--Copyright © 2000-2004 Tom Hunter
  • 31. Java Architecture • The Virtual Machine interprets the bytecode one instruction at a time, and translates it into native machine code. • You compile your program once into bytecode, but it is interpreted anew every time it runs. Java I--Copyright © 2000-2004 Tom Hunter
  • 32. Security and the “Sandbox” Java I--Copyright © 2000-2004 Tom Hunter
  • 33. Security and the “Sandbox” C and C++ are famous for speed. • One reason they are fast is because C and C++ don’t do things like checking the bounds of arrays. • In C or C++, a program can walk off the edge of an array and invade the memory space beyond. • Hackers love that about C and C++. Java I--Copyright © 2000-2004 Tom Hunter
  • 34. Security and the “Sandbox” • Another weakness of C/C++, that is a favorite among Hackers, is the Buffer Overflow. • In this attack, the Hacker floods too much data into a buffer and whatever overflows it is turned loose on the system. • Java solves these problems Java I--Copyright © 2000-2004 Tom Hunter
  • 35. Security and the “Sandbox” • How Java Combats malicious code: Java checks array boundaries Java halts Buffer Overflows Java has Garbage collection to get rid of objects that are no longer used. Java’s compiler checks to make sure the code is safe before it runs. • Gosling built security into Java, using a concept known as the “Sandbox.” Java I--Copyright © 2000-2004 Tom Hunter
  • 36. Security and the “Sandbox” Remote Code Local Code All Code, both Local and Remote, Must Pass Security Policy JDK 1.2 Security Model SANDBOX Vulnerable System Resources (files, etc) Even Local Code is Not Trusted Has Fine-Grain Access Control Java I--Copyright © 2000-2004 Tom Hunter
  • 37. Security and the “Sandbox” • 5 Steps To Writing A Java Program: 1.) Write it in a Text Editor 2.) Compiler creates bytecode 3.) The “Class loader” places the .class file in memory. 4.) The “Bytecode Verifier” makes sure the code adheres to Java’s security rules. 5.) The JVM Interpreter reads bytecode and makes platform native code. Java I--Copyright © 2000-2004 Tom Hunter
  • 38. Security and the “Sandbox” • You see, preventing problems is a major design consideration in Java. • This idea led to the most import aspect of Java: Object Orientation. • Object Orientation protects data and lets a program do only what is explicitly permitted. • You could say Java is pessimistic. Java I--Copyright © 2000-2004 Tom Hunter
  • 39. Objects in Java • In Java, Object Orientation is so pervasive that it’s nearly impossible to write a strictly procedural program in the language. Java I--Copyright © 2000-2004 Tom Hunter
  • 40. Objects in Java • Objects are reusable components. • In Java, everything must be run from a “class” file. This “class” contains bytecode. • Java source code has the extension Xxx.java Java I--Copyright © 2000-2004 Tom Hunter
  • 41. Objects in Java • If I write a Java program called: Hello.java then, when compiled, this program will be called: Hello.class Java I--Copyright © 2000-2004 Tom Hunter
  • 42. Objects in Java • A class object is compiled Java code that contains its own data variables, called members, and sections of procedural code called methods. If you have programmed in COBOL, a method is like a paragraph you perform. If you have programmed in C or C++, a method is like a function your program calls. Java I--Copyright © 2000-2004 Tom Hunter
  • 43. Objects in Java • The combination of the data variables and the methods that are used to read, write or modify those variables is called a class. Java I--Copyright © 2000-2004 Tom Hunter
  • 44. Objects in Java • Java has a rich collection of Class Libraries. • These are also known as the Java API or Application Programming Interface. • To program in Java, you must i.) Learn the Language, and ii.) Learn the Class Libraries. Java I--Copyright © 2000-2004 Tom Hunter
  • 45. Objects in Java • These class libraries greatly simplify your job as a Java programmer. • They help you to write complex programs quickly. • To master Java, you must master these class libraries. Java I--Copyright © 2000-2004 Tom Hunter
  • 46. Compiling A Java Program • You have created a Java program called Hello.java • To compile it, you run the JDK supplied utility called: javac C:javac Hello.java If this was successful, a file called: Hello.class will be produced. Java I--Copyright © 2000-2004 Tom Hunter
  • 47. First Java Program • The two largest varieties of Java programs: Applications Applets Java I--Copyright © 2000-2004 Tom Hunter
  • 48. First Java Program • A Java Application is a free-standing program that is capable of running directly in the Java Virtual Machine. • A Java Applet is a mini-program that is much more limited in its abilities. An Applet can only run within the context of an HTML browser. Java I--Copyright © 2000-2004 Tom Hunter
  • 49. A Java Application // HelloWorld.java Our first Java Application public class HelloWorld { public static void main( String args[]) { System.out.println( “Hello World!” ); } } Nowdouble slashesname. a “C++”-style comment. The our Application is complete. We have added the This is the class denote method “main”. All methodsJava lowerslashesmain is Every single bit of code in are must case. is Everything on the line after the double sit in curly brackets. a specialby the compiler. ignored names are capitalized. the program. Class method--it actually runs Words within the name are also capitalized. In any application, you are always guaranteed that method main will run.be saved in a file with the exact This Java program must same name--matching the upper case--as you see in blue above: HelloWorld.java Java I--Copyright © 2000-2004 Tom Hunter
  • 50. A Java Application C:>javac HelloWorld.java C:> • A successful compile of your java program will return to a bare cursor, as you see here. Java I--Copyright © 2000-2004 Tom Hunter
  • 51. A Java Application C:>javac HelloWorld.java C:>java HelloWorld Hello World! • To run your compiled Application, you enter lowercase java HelloWorld on the command line. • Notice, the “.class” extension is omitted. Java I--Copyright © 2000-2004 Tom Hunter
  • 52. In Class Activity Now load the JDK1.4.1, the documentation, change the class path and write your first Java program. Java I--Copyright © 2000-2004 Tom Hunter
  • 53. Java I--Copyright © 2000-2004 Tom Hunter