Lecture.1: Getting Started With Java Jiang (Jen) ZHENG May 9 th, 2005
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 2 Outline Survey Course Policies What is Java Why is Java Special The process of programming Plan of this course Getting started with Java Topics for next lecture
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 3 Survey
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 4 Course Policies Webpage: Lecture: M/W 12:30-2:15p.m. SNSQ 5129 Lab: M 02:30-04:20p.m. SNSQ 6110 Instructor: Jiang (Jen) Zheng Phone: Office: SNSQ 6501 O/H: M/W 10:00-11:30a.m. Text Book: Java By Dissection (Pohl and McDowell)
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 5 Course Polices: Totally 9 labs and 22 lectures. One midterm (06/15) and one final (07/ 27) No class on May 30 th and July 4 th Three to fours quizzes on class. Around 5 programming assignments. Grading: Midterm25% Final25% Quiz15% Assignment35% Total100%
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 6 What is Java? Computer Science is the study of algorithms and machines. Algorithms: instructions for human beings Program: instructions for computer/machines. Java is A high-level, object-oriented, interpreted, third generation programming language.
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 7 Why is Java special? Let you write a special program called applet. What is the advantage of applet? Traditional computer programs have far too much access to your system Java severely restricted what an applet can do. A Java applet can not Write to your hard disk without your permission Write to arbitrary addresses in memory
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 8 Why is Java special? Java is Object-Oriented Simpler, easier to read programs More efficient reuse of code Faster to market More robust, error-free code What is Object-Oriented? The primary mode of execution is interaction of objects with each other.
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 9 Why is Java special? Java is Platform Independent: the same.class file can be execute on any platform as long as the interpreter, Java Runtime Environment (JRE), is installed there.
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 10 Why is Java special? Java is Garbage Collected You don’t need to explicitly allocate and reallocate memory in Java. By knowing Java, you can take other courses easily, like CS445, CS1501, etc
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 11 The process of programming Understand the problem well Design the solution (algorithm) Consider alternatives Implementation Documentation Debugging Testing
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 12 Very Useful Links for Java Programmer Java APIs: Java Tutorial: javaPlace.net:
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 13 Plan of this course Plan to Cover Chapter Chapter 1-5: To learn the basics of Java language from Java implementation point of view Concept point of view Chapter 6-7: To learn the principals of Object- Oriented programming and to learn to program effectively in an Object-Oriented way.
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 14 Plan of this course Chapter 8-9:Graphical User Interfaces (GUI) and applet Chapter 10: Reading and Writing Files Chapter 11: Exceptions Handling & Chapter 12: Dynamic Data Structures
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 15 Getting Started With Java (Lab1) To Write your first program, what you need: The Java 2 Platform, Standard Edition. SDK, Software Development Kit. A text editor pico emacs vi Some Integrated Development Environment (IDE). For example, BlueJ, JBuilder, Visio Studio, etc
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 16 First Application: Hello World Three steps for develop a Java Application Create a Java source file. Compile the source file into a bytecode file. Run the program contained in the bytecode file.
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 17 First Application: Hello World
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 18 Create The Source Code Change to your home directory cd Make a subdirectory for your program mkdir CS401 Change your current directory to this directory cd CS401 Start a text editor pico HelloWorldApp.java Type in the following word class HelloWorldApp { public static void main(String[] args) { System.out.println(“Hello World!”); } } Save the file by typing Ctrl-O
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 19 Compile and Run To compile this application: javac HelloWorldApp.java To Run this application java HelloWorldApp
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 20 First Applet: Hello World Save the two files: HelloWorld.java & Hello.htm To Compile: javac HelloWorld.java To run: appletviewer Hello.htm
CS401/COE401 Summer 2005.Department of Computer Science.University of Pittsburgh 21 Topics for next lecture Reading Assignment: Chapter You don’t need to know the details but you should know what are those when I talk about it.