© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Object Oriented Programming in Java George Mason University Fall 2011
Object Oriented Programming in JAVA
1 Fall 2009ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Java: Early Objects Third Edition by Tony Gaddis Chapter.
Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
1 Fall 2007ACS Fall 2007 Text: Starting out with java from control structures through data structures Gaddis & Muganda Instructor: Ron McFadyen.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Java
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Introduction to Object-Oriented Programming Lesson 01: Introduction
LESSON 1 INTRODUCTION Compiled By: Edwin O. Okech [Tutor, Amoud University] JAVA PROGRAMMING.
Getting Started with Java
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Introduction to Java Tonga Institute of Higher Education.
Introducing Java.
Parts of a Computer Why Use Binary Numbers? Source Code - Assembly - Machine Code.
© 2012 Pearson Education, Inc. All rights reserved. Starting Out with Java: From Control Structures through Data Structures Second Edition by Tony Gaddis.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Chapter 1: Introduction to Computers and Java Starting Out with Java From.
Introduction to Java Lecture # Java History Green Team started by Sun Microsystems. *7 Handheld controller for multiple entertainment systems.
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 1 Introduction to Computers and Programming.
(C) 2010 Pearson Education, Inc. All rights reserved.  Java programs normally go through five phases  edit  compile  load  verify  execute.
 Java Programming Environment  Creating Simple Java Application  Lexical Issues  Java Class Library.
COMP 110 Spring Announcements Computers in class on Friday: Lab Office Hours: Monday 12-2 New students see me after class Administrative Changes.
COMP 110: Introduction to Programming Tyler Johnson January 14, 2009 MWF 11:00AM-12:15PM Sitterson 014.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Computer Programming A program is a set of instructions a computer follows in order to perform a task. solve a problem Collectively, these instructions.
Chapter 1: Introduction to Computers and Java
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
POS 406 Java Technology And Beginning Java Code
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Java Programming, Second Edition Chapter One Creating Your First Java Program.
CHAPTER 1 Introduction to Computers and Java Copyright © 2016 Pearson Education, Inc., Hoboken NJ.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Java: From Control Structures through Objects Third Edition.
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.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
Chapter 1: Introduction to Computers and Java 1-2 Chapter Topics Chapter 1 discusses the following main topics: –Introduction –Why Program? –Computer.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
CHAPTER 1 Introduction to Computers and Java Copyright © 2016 Pearson Education, Ltd.
Chapter 1: Introduction to Computers and Programming.
© 2012 Pearson Education, Inc. All rights reserved. Starting Out with Java: From Control Structures through Data Structures Second Edition by Tony Gaddis.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Chapter 1: Introduction to Computers and Java Starting Out with Java From.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Lecture 1b- Introduction
Key Ideas from day 1 slides
Chapter 1: Introduction to Computers and Java
Introduction CSC 111.
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Presentation transcript:

© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various devices / OS’s without rewriting/recompiling the program Java is “cross platform”

© 2012 Pearson Education, Inc. All rights reserved. 1-2 Java Applications & Applets 2 types of Java programs: – Application Stand-alone program (run without a web browser) Relaxed security since user runs program locally – Applet Small app embedded in a webpage - requires a Java enabled web browser to run app Enhanced security since user goes to a web page & applet runs itself

© 2012 Pearson Education, Inc. All rights reserved. 1-3 A Compiler 1.Programmer writes program – using high-level progr. lang. (C, C#, COBOL) – using text editor or IDE (Integrated Development Environment)  source code file = set of progr. lang. statements 2.Compiler translates it to machine language (=executable code: SomeProgram.exe )

© 2012 Pearson Education, Inc. All rights reserved. 1-4 A Compiler is a program processes: – Input data: source code file – Output data: machine language file finds syntax errors – ~ spelling, grammar, structure errors – that violate rules of that programming language.

© 2012 Pearson Education, Inc. All rights reserved. 1-5 A typical Compiler vs. the Java compiler (& the JVM) Most compilers translate source code into executable file containing machine code for a specific CPU / OS Java compiler translates a Java source file into a file containing byte code instructions Byte code instructions are the “machine language” of the Java Virtual Machine (JVM) & can NOT be executed directly by a CPU

© 2012 Pearson Education, Inc. All rights reserved. 1-6 Java Virtual Machine JVM = a program that emulates a CPU JVM executes each byte code instruction as it’s read (unlike a compiler) – So it’s called an interpreter Java = an interpreted language

© 2012 Pearson Education, Inc. All rights reserved. 1-7 Program Development Process Text editor (or IDE) Source code (.java ) Saves Java statements Java compiler ( javac ) Is read by Byte code (.class ) Produces Java Virtual Machine ( java ) Is interpreted by Program Execution Results in

© 2012 Pearson Education, Inc. All rights reserved. 1-8 Portability Portable = a program written on one type of computer can run on a wide variety of computers (with little or no modification.) Java byte code runs on the JVM (on a computer), not on any particular CPU So compiled Java programs are highly portable Specific JVMs exist for many platforms : Unix BSD etc. Windows Mac Linux

© 2012 Pearson Education, Inc. All rights reserved. 1-9 Portability most programming languages’ programs: portability achieved by compiling program for each different platform/CPU it’ll run on – so many different.exe files Java provides a JVM for each platform so no recompiling for different platforms – so only one.class (byte code) file – Byte code program runs on ANY JVM

© 2012 Pearson Education, Inc. All rights reserved Portability Java Virtual Machine for Windows Byte code (.class) Java Virtual Machine for Linux Java Virtual Machine for Mac Java Virtual Machine for Unix

© 2012 Pearson Education, Inc. All rights reserved Java Versions JDK (Java Development Kit) – software use to write Java programs different editions of JDK: – Java SE - Standard Edition. – Java EE - Enterprise Edition. – Java ME - Micro Edition. Available for download

© 2012 Pearson Education, Inc. All rights reserved Compiling a Java Program javac is the Java compiler Java compiler is a command line utility to compile a program: javac SomeProgram.java must use.java file extension IDE automates (& hides) this – Called Build (instead of compile)

© 2012 Pearson Education, Inc. All rights reserved Programming Languages Common Language Elements Some common concepts – Key words – Operators – Punctuation – Programmer-defined identifiers – Strict syntactic rules.

© 2012 Pearson Education, Inc. All rights reserved Sample Java Program – key words public class HelloWorld { public static void main(String[] args) { String message = "Hello World"; System.out.println(message); } Key words: public, class, static, void – lower case (Java is a case-sensitive) – can’t use these as programmer-defined identifiers

© 2012 Pearson Education, Inc. All rights reserved Java – lines vs. statements A statement = a complete instruction that causes the computer to perform an action. Semi-colon at end of every statement – not at end of every line System.out.println( message); This is 1 statement written on 2 lines

© 2012 Pearson Education, Inc. All rights reserved Java Variables Variables store data in a program (in memory) A variable name represents a location in memory Variables also called fields Variables are created by the programmer who specifies 1) name 2) data TYPE 3) starting value (maybe) example: int age = 18; age variable will contain an integer value; it initially stores the value 18

© 2012 Pearson Education, Inc. All rights reserved Variables Variable - a name given to a location in memory – 8 locations shown below 0x000 0x001 0x002 0x003 0x004 0x005 0x006 0x007

© 2012 Pearson Education, Inc. All rights reserved Variables 0x000 0x001 0x002 0x003 0x004 0x005 0x006 0x007 Java Virtual Machine (JVM) (not programmer) decides where in memory the declared variable is stored 72 Here’s a declaration of a varaible called length int length = 72; The variable called length is a symbolic name for the Memory location 0x003. Programmer doesn’t know it’s in 0x003.