CTIS251-Week 1 Engineering Software and Java Dr. Ozlem Albayrak.

Slides:



Advertisements
Similar presentations
A Programmer's Introduction to Java - from a S/370 user (c) IDMS/SQL News
Advertisements

L1-2:CSC ©Dr. Basheer M. Nasef Lecture #1 By Dr. Basheer M. Nasef.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Introduction to Java Kiyeol Ryu Java Programming Language.
Excerpts from Introduction to Java Programming, 4E Author: Y. Daniel Liang (Copyright by Prentice Hall)
Introduction to Java Programming, 4E
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
For more Lectures and Notes Visit
1 Chapter 1 Introduction to Computers, Programs, and Java.
Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
LESSON 1 INTRODUCTION Compiled By: Edwin O. Okech [Tutor, Amoud University] JAVA PROGRAMMING.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Java Programming Language Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 1
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
Introduction to Java Programming with JBuilder 4
S.W. Ma/CIM/LWL41211/2 Prog. IIA Page 1 HKIVE (Lee Wai Lee Campus) Department of CIM Course : Year 2 Module : Programming IIA Textbook : Introduction.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Chapter 1 Introduction to Computers, Programs, and Java 1.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
CPCS  Problem Solving in Everyday Life  Types of Problems  Problem Solving with Computers  Difficulties with Problem Solving 0-3.
1 Chapter 1 Introduction to Computers, Programs, and Java.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Programs,
Introduction to Java Programming. History F James Gosling and Sun Microsystems F Oak F Java, May 20, 1995, Sun World F HotJava –The first Java-enabled.
1.  At the end of this slide, student can:  Explore tools, features, properties and interface of the Textpad.  Creating a new project.  Open and run.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
1 Part I : Chapter 01 Introduction to Java Programming.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
1 Chapter 3 Programs and Java. 2 Objectives F To review computer programs, and operating systems. F To represent numbers in binary, decimal, and hexadecimal.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
1 Chapter 1 Java –Originally for intelligent consumer-electronic devices –Then used for creating Web pages with dynamic content –Now also used for: Develop.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
Chapter 1: Introduction to Programs, and Java 1. Objectives To review programs (§ ). To understand the relationship between Java and the World Wide.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Programs.
POS 406 Java Technology And Beginning Java Code
Introduction to Java Programming with Forte Y. Daniel Liang.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved What is a Computer? A computer.
Object Oriented Rabie A. Ramadan, PhD Slides are exerted from different sources.
Introduction to Java Programming. Introduction Course Objectives Organization of the Book.
Introduction To JAVA By Ihtesham Ul Haq. Course Objectives Upon completing the course, you will understand Upon completing the course, you will understand.
1 Chapter 3 Introduction to Computers, Programs, and Java.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Cs205: engineering software university of virginia fall 2006 Introducing Java David Evans Don’t forget to your registration.
Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Introduction to Java Programming. 2 Chapter 1 Introduction to Java and Forte F What Is Java? F Getting Started With Java Programming –Create, Compile.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
1 Chapter 1 Introduction to Computers, Programs, and Java.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Introduction to JAVA Programming
Introduction to Java Programming, 4E Y. Daniel Liang.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Chapter 1 Introduction to Computers, Programs, and Java
Java programming lecture one
Chapter 1 Introduction to Computers, Programs, and Java
Introduction to Java.
Advanced Programming Fall 2017.
Chapter 1 Introduction to Computers, Programs, and Java
Anatomy of a Java Program
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:

CTIS251-Week 1 Engineering Software and Java Dr. Ozlem Albayrak

2 Menu F Introduction to the CTIS251 elements F What is Engineering? –Can we engineer software? F Introduction to the java language programming concepts F Primitive Data Types and Operations

3 Introduction to CTIS251 Course Elements: - Instructor - Students - Course Material

4 Instructor F Dr. Ozlem Albayrak –Computer Eng. Bilkent, 1992 –M.B.A., Bilkent, 1994 –M.S., UMCP, 1998 –Phd., Ankara, 2002 Room# 212 Phone:

5 The Students F Attendance - Bonuses F Get to Know F Why are you here? F Expectations F Interests

6 Office Hour? Tuesday 14:40 – 15:30 Thursday 8:40 – 10:30 via or phone for appointment

7 Course Material Not limited to: F Syllabus F The main text book F References F All related high quality sources

8 Syllabus F Distributed syllabus will be reviewed –Subjects –Grading (bonus questions) –Labs

9 Syllabus (1) WeekChapters 1Introduction to the course, basic java language programming concepts: Primitive Data Types and Operations 1, 2 2Methods, Control Statements, Arrays4, 3, 5 3Object Oriented Programming: Objects and Classes6 4Data Member, Member Method, Static and final members. Constructor 6 5Visibility Modifiers, Acessors, and Mutators6 6Inheritance, Object Class8 7Review + Array of Objects, Some handy Java Classes; Arrays, String, StringBuffer, StringTokenizer, Vector 7 8MIDTERM

10 Syllabus (2) 9 Array of Objects, Some handy Java Classes; Arrays, String, StringBuffer, StringTokenizer, Vector 7 10 Concrete class, Abstract Class, Interface 9 11 Polymorphism 8 12 Error Handling, Exception Classes and Custom Java Exceptions GUI Programming, event driven programming, components and containers, AWT (Abstract Window Toolkit), swing 11, 12, GUI Programming, event driven programming, components and containers, AWT (Abstract Window Toolkit), swing 11, 12, GUI Programming, Applet Review 17 FINAL

11 What is Engineering?

12 Webster’s Definitions en·gi·neer·ing ( n j -nîr ng) n. The application of scientific and mathematical principles to practical ends such as the design, manufacture, and operation of efficient and economical structures, machines, processes, and systems. Problem solvers

13 How is engineering software different from engineering bridges?

14 F Continuous –Calculus –Testing/analysis is easy: if the bridge holds for 1M kg, it also probably holds 0.99Mkg F Discrete –Logic, Discrete Mathematics –Testing/analysis is difficult Bridges Software

15 F Made of physical stuff –Some costs are obvious –Changes after construction are hard F Made of virtual stuff –All costs are non- obvious –Changes should be easy (but they’re not) Bridges Software for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { nextStates [i][j] = getCellAt (i, j).getNextState (); }

16 F Obvious when it fails –Bridge makers get sued –Architects need licenses F Falls down quietly (usually) –Software vendors blame user, charge for upgrades –Anyone can make software, no one gets sued Bridges Software

17 F Requirements are (usually) obvious and easy to describe F A good design is apparent to everyone immediately F Requirements are mysterious and hard to describe F A good design is only apparent to “experts” but has impact later on Bridges Software Grid CellAutomata Cell CellState GridDisplay ConwayLifeCell is a subtype of (extends)

18 JAVA

19 Google search about Java.... F Returns approximately yaklaşık result !

20 Java Sources on the net F amming_language%29 F F F F Books:

21 What is Java? A. Island in Indonesia known for coffee and volcanoes B. A Programming Language (Java  ) C. A Portable Low-Level Language (JVML) D. A Platform (JavaVM) E. A (semi-)successful marketing strategy –JavaScript is not related to Java or Java  F. All of the above

22 Compiling C++ Programs #include main( int argc, char *argv[]) { // do something }

23 The Java Virtual Machine class Hello { public static void main(String[] args) { System.out.println( “Hello World” ); } Hello.java … Method Hello() 0 aload_0 1 invokespecial #1 4 return Method void main(java.lang.String[]) 0 getstatic #2 3 ldc #3 5 invokevirtual #4 8 return Hello.class javac

24 The Java Virtual Machine class Hello { public static void main() { // do something } Mac JVMLinux JVM Win JVM Hello.class

25 Java  : Programming Language “A simple, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high- performance, multithreaded, and dynamic language.” [Sun95] By the end of the course, you should have a good idea if this is a true statement.

26 Platform Independence F C++ compiles to native code for a specific architecture (Linux, Windows…) F Java compiles to Java bytecode F Same bytecode runs on virtual machine for any platform –Only VM is platform specific –Good for downloadable code –Applets etc

27 Java F Syntax –Similar to C++ –Designed to be easy for C and C++ programmers to learn F Semantics (what programs mean) –Similar to Scheme –Designed to make it easier to reason about properties of programs

28 Programming Systems Scheme Interpreter Scheme Program C++ Compiler C++ Program Machine Object Files

29 Java VM F Portability –If you can implement a Java VM on your machine, then you can run all Java programs F Security –A VM can limit what programs can do to the real machine F Simplicity –VM instructions can be simpler than machine instructions Java Compiler Java Program Java Virtual Machine Class Files Machine Why use a virtual machine?

30 Programming in Java F Program is divided into classes F A class: –Defines a new datatype –Defines methods and state associated with that datatype F We call a value of a class datatype an object –Objects package state and code

Introduction to Java Programming with JBuilder, 3E Y. Daniel Liang

32 Sequence of the Topics

33 Course Objectives F Upon completing the course, you will understand –Create, compile, and run Java programs –Primitive data types –Java control flow –Methods –Arrays (for teaching Java in two semesters, this could be the end) –Object-oriented programming –Core Java frameworks (Swing, exception, I/O, collections, multithreading, multimedia, )

34 Course Objectives, cont. F You will be able to –Develop programs using various tools –Write simple programs using primitive data types, control statements, methods, and arrays –Understand object-oriented concepts and principles: abstraction, encapsulation, inheritance, and polymorphism –Develop a GUI interface and Java applets –Deal with exceptions in the program –Store and retrieve data using Java I/O –Use data structures from the Java Collections framework –Establish a firm foundation on Java concepts

35 Chapter Dependency Chart

36 Book Chapters F Part I: Fundamentals of Programming –Chapter 1 Introduction to Java and JBuilder –Chapter 2 Primitive Data Types and Operations –Chapter 3 Control Statements –Chapter 4 Methods –Chapter 5 Arrays

37 Book Chapters, cont. F Part II: Object-Oriented Programming –Chapter 6 Objects and Classes –Chapter 7 Strings –Chapter 8 Inheritance and Polymorphism –Chapter 9 Abstract Classes and Interfaces –Chapter 10 Object-Oriented Analysis and Design

38 Book Chapters, cont. F Part III: GUI Programming –Chapter 11 Getting Started with GUI Programming –Chapter 12 Event-Driven Programming –Chapter 13 Creating User Interfaces –Chapter 14 Applets

39 Book Chapters, cont. F Part IV: Developing Comprehensive Projects –Chapter 15 Exceptions and Assertions –Chapter 16 Input and Output –Chapter 17 Java Data Structures –Chapter 18 Multithreading –Chapter 19 Multimedia

40 Bonus Chapters on the CD-ROM F Part V: Bonus Chapters –Chapter 20 Internationalization –Chapter 21 Networking –Chapter 22 Database Programming –Chapter 18 Servlets –Chapter 19 JavaServer Pages

41 Chapter 1 Introduction to Java and JBuilder F What Is Java? F Getting Started With Java Programming –Create, Compile and Running a Java Application

42 What Is Java? F History F Characteristics of Java

43 History F James Gosling and Sun Microsystems F Oak F Java, May 20, 1995, Sun World F HotJava –The first Java-enabled Web browser F JDK Evolutions F J2SE, J2ME, and J2EE (not mentioned in the book, but could discuss here optionally)

44 Characteristics of Java F Java is simple F Java is object-oriented F Java is distributed F Java is interpreted F Java is robust F Java is secure F Java is architecture-neutral F Java is portable F Java’s performance F Java is multithreaded F Java is dynamic

45 JDK Versions F JDK 1.02 (1995) F JDK 1.1 (1996) F Java 2 SDK v 1.2 (a.k.a JDK 1.2, 1998) F Java 2 SDK v 1.3 (a.k.a JDK 1.3, 2000) F Java 2 SDK v 1.4 (a.k.a JDK 1.4, 2002) F...

46 JDK Editions F Java Standard Edition (J2SE) – J2SE can be used to develop client-side standalone applications or applets. F Java Enterprise Edition (J2EE) – J2EE can be used to develop server-side applications such as Java servlets and Java ServerPages. F Java Micro Edition (J2ME). – J2ME can be used to develop applications for mobile devices such as cell phones. This book uses J2SE to introduce Java programming.

47 Java IDE Tools F Forte by Sun MicroSystems F Borland JBuilder F Microsoft Visual J++ F WebGain Café F IBM Visual Age for Java F IBM WSAD

48 Getting Started with Java Programming F A Simple Java Application F Compiling Programs F Executing Applications

49 A Simple Application Example 1.1 //This application program prints Welcome //to Java! package chapter1; public class Welcome { public static void main(String[] args) { System.out.println("Welcome to Java!"); } Run Source IMPORTANT NOTE: To run the program from the Run button, (1) set c:\jbuilder9\jdk1.4\bin on your path, and (2) copy both the slide directory and the example directory from the IR-CD to a directory (e.g., c:\LiangIR-CD).

50 Anatomy of a Java Program F Comments F Package F Reserved words F Modifiers F Statements F Blocks F Classes F Methods F The main method

51 Comments In Java, comments are preceded by two slashes (//) in a line, or enclosed between /* and */ in one or multiple lines. When the compiler sees //, it ignores all text after // in the same line. When it sees /*, it scans for the next */ and ignores any text between /* and */.

52 Package The second line in the program (package chapter1;) specifies a package name, chapter1, for the class Welcome. Forte compiles the source code in Welcome.java, generates Welcome.class, and stores Welcome.class in the chapter1 folder.

53 Reserved Words Reserved words or keywords are words that have a specific meaning to the compiler and cannot be used for other purposes in the program. For example, when the compiler sees the word class, it understands that the word after class is the name for the class. Other reserved words in Example 1.1 are public, static, and void. Their use will be introduced later in the book.

54 Modifiers Java uses certain reserved words called modifiers that specify the properties of the data, methods, and classes and how they can be used. Examples of modifiers are public and static. Other modifiers are private, final, abstract, and protected. A public datum, method, or class can be accessed by other programs. A private datum or method cannot be accessed by other programs. Modifiers are discussed in Chapter 6, “Objects and Classes.”

55 Statements A statement represents an action or a sequence of actions. The statement System.out.println("Welcome to Java!") in the program in Example 1.1 is a statement to display the greeting "Welcome to Java!" Every statement in Java ends with a semicolon (;).

56 Blocks A pair of braces in a program forms a block that groups components of a program.

57 Classes The class is the essential Java construct. A class is a template or blueprint for objects. To program in Java, you must understand classes and be able to write and use them. The mystery of the class will continue to be unveiled throughout this book. For now, though, understand that a program is defined by using one or more classes.

58 Methods What is System.out.println? It is a method: a collection of statements that performs a sequence of operations to display a message on the console. It can be used even without fully understanding the details of how it works. It is used by invoking a statement with a string argument. The string argument is enclosed within parentheses. In this case, the argument is "Welcome to Java!" You can call the same println method with a different argument to print a different message.

59 main Method The main method provides the control of program flow. The Java interpreter executes the application by invoking the main method. The main method looks like this: public static void main(String[] args) { // Statements; }

60 Creating, Compiling, and Running Programs

61 Executing Applications F On command line –java classname

62 Example javac Welcome.java java Welcome output:...

63 JBuilder Basics F Installing JBuilder F JBuilder IDE Interface F Create a JBuilder project F Create Java programs F Compile and run Java programs

64 JBuilder IDE Interface

65 Creating a JBuilder project Choose File, New Project to display the project wizard

66 Creating a JBuilder project, cont. Set output path, backup path, working directory, and source path

67 Creating a JBuilder project, cont. Optional project description

68 Creating a Java Program Choose File, New Class to display the class wizard

69 Compiling and Running a Program Where are the files stored in the directory?

70 Displaying Text in a Message Dialog Box you can use the showMessageDialog method in the JOptionPane class. JOptionPane is one of the many predefined classes in the Java system, which can be reused rather than “reinventing the wheel.” Run Source IMPORTANT NOTE: To run the program from the Run button, (1) set c:\jbuilder9\jdk1.4\bin on your path, and (2) copy both the slide directory and the example directory from the IR-CD to a directory (e.g., c:\LiangIR-CD).

71 The showMessageDialog Method JOptionPane.showMessageDialog(null, "Welcome to Java!", "Example 1.2", JOptionPane.INFORMATION_MESSAGE));

72 The exit Method Use Exit to terminate the program and stop all threads. NOTE: When your program starts, a thread is spawned to run the program. When the showMessageDialog is invoked, a separate thread is spawned to run this method. The thread is not terminated even you close the dialog box. To terminate the thread, you have to invoke the exit method.

73 Review F Introducttion to course elements F Introduction to Java basics F Review F Next: –Primitive Data Types and operations