 2005 Pearson Education, Inc. All rights reserved. 1 Introduction & The Java Virtual Machine Small Java Chapter 1 1.

Slides:



Advertisements
Similar presentations
 2008 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
Advertisements

Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
CSCE 145: Algorithmic Design I Chapter 1 Intro to Computers and Java Muhammad Nazmus Sakib.
 2005 Pearson Education, Inc. All rights reserved Introduction.
 2002 Prentice Hall. All rights reserved. Chapter 1 – Introduction to Computers, the Internet, and the Web Java, How to Program, 4 th Edition, by Deitel.
Visual and Internet Programming using JAVA
Object Orientated Programming
 2005 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and the World Wide Web.
Chapter 1 Introduction to Object- Oriented Programming and Problem Solving.
Java Environment (CSS444)
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 1 – Introduction to Computers, the Internet, and the Web Outline 1.1 Introduction 1.2 What Is.
 2006 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and the World Wide Web.
Introduction to Computer Programming CSC 1401: Introduction to Programming with Java Lecture 2 Wanda M. Kunkle.
 2002 Prentice Hall. All rights reserved. Week 1 - Introduction to Object- Oriented Programming Outline 1.1 Machine Languages, Assembly Languages and.
 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and the World Wide Web.
Java How to Program, 9/e Instructor: José M. Reyes Álamo © by Pearson Education, Inc. All Rights Reserved.
 2000 Prentice Hall, Inc. All rights reserved. 1 Introduction to Computers and C Programming Outline Introduction What Is a Computer? Computer Organization.
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
 2003 Prentice Hall, Inc. All rights reserved. Chapter 1 – Introduction to Computers, the Internet, and the Web Outline 1.1 Introduction 1.2 What Is a.
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Program development & programming languages Chapter 13.
1 Chapter 1 - Introduction to Computers, the Internet, and the World Wide Web Outline 1.1Introduction 1.2What Is a Computer? 1.3Computer Organization 1.4Evolution.
1 1 1 Introduction to Java. 2 History of Java Java – Originally for intelligent consumer-electronic devices – Then used for creating Web pages with dynamic.
 2008 Pearson Education, Inc. All rights reserved. 1 The chief merit of language is clearness. — Galen Our life is frittered away by detail…. Simplify,
 2008 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
 2003 Prentice Hall, Inc. All rights reserved. 1 Java Training Course Dr. H.E. Dunsmore Purdue University Java – How to Program, Deitel (5 th Edition)
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
111 © 2002, Cisco Systems, Inc. All rights reserved.
 2005 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and the World Wide Web.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 1 – Car Payment Calculator and Guess the Number.
Programming in Java This is a one semester course. You will learn the language and some basic programming skills. You are expected to read, program,
 2002 Prentice Hall. All rights reserved. Chapter 1 – Introduction to Computers, the Internet, and the Web Outline 1.1 Introduction 1.2 What Is a Computer?
1.8History of Java Java –Based on C and C++ –Originally developed in early 1991 for intelligent consumer electronic devices Market did not develop, project.
1 Chapter 1 Introduction to Java. 2 History of Java Java Originally for _________________________ devices Then used for creating Web pages with __________________________.
Chapter 1: Introduction to Programs, and Java 1. Objectives To review programs (§ ). To understand the relationship between Java and the World Wide.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Introduction to Computers Outline 1.1Introduction.
 2006 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
 2006 Pearson Education, Inc. All rights reserved. 1 C++ How to Program, 5th Edition Deitel Dev C++
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 1 - Introduction to Computers, the Internet, and the World Wide Web Outline 1.1Introduction 1.2What.
CT1513 Introduction To java © A.AlOsaimi.
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
 2008 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Spring 2013 Lecture 1: Introduction.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
Java How to Program, 9/e Presented by: José M. Reyes Álamo © by Pearson Education, Inc. All Rights Reserved.
1 Introduction Read D&D Sec 1.8; Sec 1.13 THE Java tutorial -
 Pearson Education, Inc. All rights reserved Introduction to Computers and Java.
1 Chapter 1 Java –Originally for intelligent consumer-electronic devices –Then used for creating Web pages with dynamic content –Now also used for: Develop.
1 1 1 Introduction to Java. 2 History of Java Java – Originally for intelligent consumer-electronic devices – Then used for creating Web pages with dynamic.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Chapter 1 – Introduction to Computers, the Internet, and the Web Outline 1.1 Introduction 1.2 What Is a Computer? 1.3 Computer Organization 1.4 Evolution.
 2007 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and Visual Basic.
 2006 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and World Wide Web.
 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and the World Wide Web.
Introduction to Computers, the Internet and the World Wide Web
Introduction to Computers, the Internet and the World Wide Web
Chapter 1 – Introduction to Computers, the Internet, and the Web
CSCI-235 Micro-Computer Applications
Chapter 1 – Introduction to Computers, the Internet, and the Web
Introduction to Computers, the Internet and the World Wide Web
Chapter 1 – Introduction to Computers, the Internet, and the Web
Introduction to Computers, the Internet and the World Wide Web
Introduction to Computers, the Internet and the World Wide Web
Chapter 1 – Introduction to Computers, the Internet, and the Web
Presentation transcript:

 2005 Pearson Education, Inc. All rights reserved. 1 Introduction & The Java Virtual Machine Small Java Chapter 1 1

 2005 Pearson Education, Inc. All rights reserved. Machine Languages, Assembly Languages and High-Level Languages Machine language – 1’s and 0’s – Machine dependent Assembly language – English-like abbreviations represent computer operations – Translator programs convert to machine language – ADD 12,14 High-level language – Allows for writing more “English-like” instructions – Contains commonly used mathematical operations – Compiler converts to machine language – If X < 12 THEN … Interpreter – Execute high-level language programs without compilation 2

 2005 Pearson Education, Inc. All rights reserved. FORTRAN, COBOL, Pascal and Ada FORTRAN – FORmula TRANslator COBOL – COmmon Business Oriented Language Pascal – Structured programming Ada – Multitasking 3

 2005 Pearson Education, Inc. All rights reserved. BASIC, Visual Basic, Visual C++, C# and.NET BASIC – Beginner’s All-Purpose Symbolic Instruction Code.NET –.NET platform Visual Basic.NET – Based on BASIC Visual C++ – Based on C++ C# – Based on C++ and Java 4

 2005 Pearson Education, Inc. All rights reserved. History of Java – Originally for intelligent consumer-electronic devices – Then used for creating Web pages with dynamic content – Now also used to: Develop large-scale enterprise applications Provide applications for consumer devices (cell phones, etc.) 5

 2005 Pearson Education, Inc. All rights reserved. Java Is Not JavaScript! Java is a programming language. You write programs in it and compile them. Javascript is imbedded in a web page and run by Internet Explorer or Firefox Java applets are programs that run in a web browser We will only get to Java applications 6

 2005 Pearson Education, Inc. All rights reserved. With C++ and most compiled languages 7 Compiler For Windows PC Your Program If x = 5 then… PC with Windows Compiler For Mac Mac Source Code

 2005 Pearson Education, Inc. All rights reserved. Java Virtual Machine 8 Java Compiler Your Program If x = 5 then… PC with Windows ByteCode Windows JVMMac JVM Mac Source Code

 2005 Pearson Education, Inc. All rights reserved. Java Virtual Machine Why and how is this different? Write once, run anywhere – Bytecode is a ‘universal language’ Why isn’t all software written like this? – Xbox 360 games would work on PS 3… 9

 2005 Pearson Education, Inc. All rights reserved. Software Engineering Observation Use a building-block approach to create programs. Avoid reinventing the wheel—use existing pieces wherever possible. Called software reuse, this practice is central to object-oriented programming. 10

 2005 Pearson Education, Inc. All rights reserved. Java Class Libraries Classes – Include methods (functions) that perform tasks Return information after task completion – Used to build Java programs Java provides class libraries (of functions or methods) – Known as Java APIs (Application Programming Interfaces) – The stuff built-in to Java – Don’t re-invent the wheel! 11

 2005 Pearson Education, Inc. All rights reserved. Software Engineering Observation When programming in Java, you will typically use the following building blocks: Classes and methods from class libraries, Classes and methods you create yourself Classes and methods that others create and make available to you. 12

 2005 Pearson Education, Inc. All rights reserved. Performance Tip Using Java API classes and methods instead of writing your own versions can improve program performance, because they are carefully written to perform efficiently. This technique also shortens program development time. 13

 2005 Pearson Education, Inc. All rights reserved. Typical Java Development Environment Java programs normally undergo five phases – Edit Programmer writes program (and stores program on disk) – Compile Compiler creates bytecodes from program – Load Class loader stores bytecodes in memory – Verify Bytecode Verifier confirms bytecodes do not violate security restrictions – Execute JVM translates bytecodes into machine language 14

 2005 Pearson Education, Inc. All rights reserved. 15 Fig. 1.1 | Typical Java development environment.

 2005 Pearson Education, Inc. All rights reserved. Common Programming Error Errors like division by zero occur as a program runs, so they are called runtime errors or execution-time errors. Fatal runtime errors cause programs to terminate immediately without having successfully performed their jobs. Nonfatal runtime errors allow programs to run to completion, often producing incorrect results. 16

 2005 Pearson Education, Inc. All rights reserved. Good Programming Practice Your computer and compiler are good teachers. Study each error or warning message you get when you compile your programs (called compile-time errors or compilation errors), and correct the programs to eliminate these messages. 17

 2005 Pearson Education, Inc. All rights reserved. Portability Tip It is easier to write portable programs in Java than in other programming languages Portable to other platforms (from X-box to PS3) However, differences between compilers, JVMs and computers can make portability difficult to achieve. Simply writing programs in Java does not guarantee portability. 18

 2005 Pearson Education, Inc. All rights reserved. Error-Prevention Tip Always test your Java programs on all systems on which you intend to run them, to ensure that they will work correctly for their intended audiences. 19

 2005 Pearson Education, Inc. All rights reserved. Software Engineering Observation The Java Development Kit comes with source code for the Java API classes to determine how the classes work and to learn additional programming techniques. 20

 2005 Pearson Education, Inc. All rights reserved. 21 Fig. 1.2 | Opening a Windows XP Command Prompt and changing directories. Using the cd command to change directories File location of the ATM application Test-Driving a Java Application Using Command Line

 2005 Pearson Education, Inc. All rights reserved. 22 Fig. 1.3 | Using the java command to execute the ATM application.

 2005 Pearson Education, Inc. All rights reserved. 23 Fig. 1.4 | Prompting the user for an account number. ATM welcome messageEnter account number prompt

 2005 Pearson Education, Inc. All rights reserved. 24 Fig. 1.5 | Entering a valid PIN number and displaying the ATM application's main menu. Enter valid PINATM main menu

 2005 Pearson Education, Inc. All rights reserved. 25 Fig. 1.6 | ATM application displaying user account balance information. Account balance information

 2005 Pearson Education, Inc. All rights reserved. 26 Fig. 1.7 | Withdrawing money from the account and returning to the main menu. ATM withdrawal menu

 2005 Pearson Education, Inc. All rights reserved. 27 Fig. 1.8 | Checking new balance. Confirming updated account balance information after withdrawal transaction

 2005 Pearson Education, Inc. All rights reserved. 28 Fig. 1.9 | Ending an ATM transaction session. ATM goodbye message Account number prompt for next user

 2005 Pearson Education, Inc. All rights reserved. Programming Paradigms Traditional Programming vs. Object Oriented Programming Software objects attempt to model the real world Objects have data (attributes) and behaviors (methods or functions) 29

 2005 Pearson Education, Inc. All rights reserved. Software Engineering Case Study: Introduction to Object Technology and the UML Object orientation Unified Modeling Language (UML) – Graphical language that uses common notation – Allows developers to represent object-oriented designs 30

 2005 Pearson Education, Inc. All rights reserved. Software Engineering Case Study (Cont.) Objects – Reusable software components that model real-world items – People, animals, plants, cars, etc. – Attributes Size, shape, color, weight, etc. – Behaviors Babies cry, crawl, sleep, etc. 31

 2005 Pearson Education, Inc. All rights reserved. Software Engineering Case Study Object-oriented design (OOD) – Models real-world objects – Models communication among objects – Encapsulates attributes and operations (behaviors) Information hiding Communication through well-defined interfaces Object-oriented language – Programming in object-oriented languages is called object-oriented programming (OOP) – Java 32

 2005 Pearson Education, Inc. All rights reserved. Software Engineering Case Study Object-Oriented Analysis and Design (OOA/D) – Essential for large programs – Analyze program requirements, then develop solution – UML Unified Modeling Language 33

 2005 Pearson Education, Inc. All rights reserved. Software Engineering Case Study UML – Graphical representation scheme – Enables developers to model object-oriented systems – Flexible and extensible 34 Player health armor Run (direction) Fire (coordinates) jump