• No results found

CS 209 Programming in Java #1

N/A
N/A
Protected

Academic year: 2021

Share "CS 209 Programming in Java #1"

Copied!
8
0
0

Loading.... (view fulltext now)

Full text

(1)

1

CS 209 Programming in Java

#1

Introduction

Spring, 2006

Instructor: J.G. Neal

2

Topics

• CS 209 Target Audience

• CS 209 Course Goals

• CS 209 Syllabus - See handout

• Java Features, History, Environment

• Java Development Software

• Information Sources

• Applications and Applets

(2)

3

CS 209 Programming in Java

Target audience:

– Designed for students with previous programming experience

– Ideally the student should have some experience with: • Arrays,

• Functions/procedures,

• Passing parameters to functions/procedures

CS 209 - Course Goals

Goals:

– Learn the Java programming language

– Learn about the Java Virtual Machine and Java API – Learn to design, develop, debug, and run Java programs

• Web-based Java applets • Stand-alone Java applications – Learn to use Java development tools – Learn to use good principles and practices

(3)

5

Features of Java

• Provides for both web-based and stand-alone applications • Is totally object-oriented

• Provides networking capabilities for distributed systems • Provides for dynamic interactive programs

• Simplifies memory management - automatic garbage collection • Supports multithreading - concurrent processing

• Is portable and platform independent; interpreted

– Programs run on the Java Virtual Machine at runtime • Provides for security

• Very large set of library packages in the Java API

– Graphics, user interface capabilities, networking, database operations, file manipulations, etc.

6

Some Java History

• Developed in the early 1990’s at Sun Microsystems

– Originally called “Oak”

– Designed for use in embedded consumer electronic applications

• Redesigned for developing Internet applications and renamed “Java”

• Releases:

– JDK 1.0, the first Java programming language release, was officially announced in May 1995

– JDK 1.1 released in 1997

– Java 2 SDK v 1.2 (a.k.a. JDK 1.2), 1998 – Java 2 SDK v 1.3 (a.k.a. JDK 1.3), 2000 – Java 2 SDK v 1.4 (a.k.a. JDK 1.4), 2002 – Java 2 SDK v 1.5 (a.k.a. JDK 1.5), 2004

(4)

7

JDK Editions

• Java Standard Edition (J2SE) **

– J2SE can be used to develop client-side standalone applications or applets.

• Java Enterprise Edition (J2EE)

– J2EE can be used to develop server-side applications such as Java servlets and Java ServerPages.

• Java Micro Edition (J2ME).

– J2ME can be used to develop applications for mobile devices such as cell phones.

** This course uses the J2SE

Java Program (MyProgram.java) Java Compiler (javac) Java Bytecode (MyProgram.class) HW-based Platform (Sun + Solaris OS) Java API

Interpreter or Java Platform:

Java Virtual Machine

HW-based Platform (PC + WIN OS) Java API

Interpreter or Java Platform:

Java Virtual Machine

HW-based Platform (Mac + Mac OS) Java API

Interpreter or Java Platform:

Java Virtual Machine

The Java

Environment

Editor

(Source Code File)

(5)

9

Java Development Software

Sun Microsystems, Inc.

• Java 2 Standard Edition (J2SE) SDK from Sun Microsystems

– No cost download from the Sun Microsystems website

• J2SE includes:

• javac - Compiler for the Java language

• java - Launcher for execution of Java applications

• javadoc - API documentation generator

• appletviewer - Run applets without a web browser

• jar - Manage Java Archive (JAR) files

• jdb - Java Debugger

• javah - C header and stub generator

• javap - Class file disassembler

• extcheck - Utility to detect Jar conflicts

• HtmlConverter - Converts to a new HTML file with tags for invoking the Java plugin

• among others . . .

10

Java Development Software

Integrated Development Environments (IDEs):

• NetBeans IDE (http://www.netbeans.org; http://www.sun.com)

• Eclipse IDE (http://www.eclipse.org)

• Borland JBuilder (http://www.borland.com)

• Sun Java Studio (http://www.sun.com)

• IBM WebSphere (http://www.ibm.com)

• JCreator (http://www.jcreator.com)

(6)

11

Object-Oriented Programming

Benefits:

– Software modularity – Information hiding

– A wealth of well-tested predefined classes, especially the Java API (part of the J2SE)

– Software reuse

– Enhanced programmer productivity

Object-Oriented Programming

• Fundamental principle:

– Encapsulation of data and methods in an object

• Objects:

– Real world objects have state (attributes or data) and behavior (actions or operations)

– A software object

• maintains its state (attributes or data) in variables and • implements its behavior as methods

• A class:

– Is a “blueprint” or “template”

– Defines the variables and methods common to all objects of a certain kind

• An object is an instance of a class

(7)

13

Object-Oriented Fundamentals

• Programs are developed in the form of classes:

– The conceptual entities/objects that comprise the program

• Classes are organized into a hierarchy

– Levels:

• The higher the level, the more generic • The lower the level, the more specific

– Inheritance: subclasses automatically have the variables and methods of their superclasses

– Inherited methods can be overridden in a subclass

• Programmers write their new programs building on the existing Java Class Hierarchy (Java 2 API)

Bicycles

Racing Bikes

Mountain Bikes Tandem Bikes

14

Example Application-Specific Hierarchy

Example Application-Specific Hierarchy

Employee

SalariedEmployee HourlyEmployee TemporaryEmployee

Tier1 Tier2 Tier3 Union NonUnion Category1 Category2 Level 1:

Level 2:

(8)

15

Type of Java Programs

• Application - two types

– Console-based program: Input and output are typically from/to the command prompt window

– Window-based program: User interaction (input and output) is performed by way of a graphical user interface (GUI)

• Applet

– Runs within a web browser (e.g., Microsoft Internet Explorer, Netscape, Mozilla, Opera)

– Requires an HTML page containing an Applet tag or Object tag that holds the information needed to invoke the applet – To view an applet use:

• Web browser or • JDK appletviewer

References

Related documents

Whilst this particular submission relates to the application of Smart ICT to improve the design and planning of Infrastructure, Bentley Systems does not believe that the

There are many augmented reality (AR) applications avail- able that can be used to create educational contents for these mobile devices. This paper surveys the most popular

(B) the adsorption at a single site on the surface may involve multiple molecules at the same time.. (C) the mass of gas striking a given area of surface is proportional to the

Judith Kates is Professor of Jewish Women's Studies at Hebrew College, currently teaching Bible and Jewish traditions of commentary for the new Rabbinical School

Acutely exposed animals require calcium gluconate (IV) and oral magnesium hydroxide or milk to bind fluoride before absorption. In chronic exposure, control is difficult unless

Every time the in-memory data structure for a particular column family is dumped to disk we set its bit in the commit log stating that this column family has been successfully

The point at which the resultant of lift forces acts is: A) the hub. B) the center of gravity. D) the center of pressure.. A) airflow velocity increasing downward having been

The VX Cycle offers a broad range of scales for the cost-effective production of LNG/CCNG, and the Cycle can be integrated with existing CNG stations, pipeline compressor stations