• Tidak ada hasil yang ditemukan

PPT Slide 1

N/A
N/A
Nguyễn Gia Hào

Academic year: 2023

Membagikan "PPT Slide 1"

Copied!
37
0
0

Teks penuh

(1)

Data Structures for Java Data Structures for Java

William H. Ford William H. Ford William R. Topp William R. Topp

Appendix E Appendix E

The EZJava IDE

The EZJava IDE

(2)

EZJava EZJava

EZJava is an Integrated Development EZJava is an Integrated Development

Environment (IDE) that allows you to develop Environment (IDE) that allows you to develop

and run Java programs on a Windows, Linux, and run Java programs on a Windows, Linux,

Solaris, or Macintosh OS X system.

Solaris, or Macintosh OS X system.

Can select an appropriate look-and-feel for your Can select an appropriate look-and-feel for your system.

system.

Allows you to compile and run a main class along Allows you to compile and run a main class along with any supporting classes in the same directory.

with any supporting classes in the same directory.

Can create a project consisting of many source files Can create a project consisting of many source files within a package structure.

within a package structure.

(3)

EZJava (continued) EZJava (continued)

Can open multiple editing windows in tab panes, Can open multiple editing windows in tab panes,

search a file hierarchy for a pattern that can include search a file hierarchy for a pattern that can include the use of regular expressions, and run programs the use of regular expressions, and run programs with a debugger.

with a debugger.

Editing and printer options allow you to set fonts Editing and printer options allow you to set fonts and tabs, execute find/replace commands, and and tabs, execute find/replace commands, and reformat text by replacing tabs with blanks and reformat text by replacing tabs with blanks and changing cases.

changing cases.

Provides options for automatically creating program Provides options for automatically creating program documentation and for setting paths to the class

documentation and for setting paths to the class and jar files required by applications.

and jar files required by applications.

(4)

EZJava (continued) EZJava (continued)

New documents can be created using New documents can be created using

templates for console and GUI applications as templates for console and GUI applications as well as applet programs and their associated well as applet programs and their associated HTML files.

HTML files.

An application executes in its own runtime An application executes in its own runtime window with a command button for multiple window with a command button for multiple runs.

runs.

Compiles Synchronous Java, which is an Compiles Synchronous Java, which is an extension of Java with concurrent

extension of Java with concurrent

(5)

Installation Installation

Install a version of Java SDK and create a Install a version of Java SDK and create a PATH entry to the bin directory of the

PATH entry to the bin directory of the SDK.

SDK.

Download from Download from www.EZJava.orgwww.EZJava.org..

(6)

Installation (continued) Installation (continued)

Windows: After uncompressing theWindows: After uncompressing the ZIP file

ZIP file

Double-click the batch file EZJavaInstall.bat. This Double-click the batch file EZJavaInstall.bat. This brings up a self explanatory GUI application that brings up a self explanatory GUI application that

guides you through the installation.

guides you through the installation.

(7)

Installation (continued) Installation (continued)

Unix: After uncompressing the ZIP fileUnix: After uncompressing the ZIP file

Change into the download directory and Change into the download directory and execute the command

execute the command

java -jar EZJavaInstaller.jar java -jar EZJavaInstaller.jar that runs the installer.

that runs the installer.

(8)

Installation (concluded) Installation (concluded)

OS X: Run the dmg file to mount the OS X: Run the dmg file to mount the

installation volume. Drag the EZJava icon installation volume. Drag the EZJava icon

to the Applications folder. Also, please run to the Applications folder. Also, please run

the registration application.

the registration application.

(9)

Getting Started Getting Started

On a Windows system, start up EZJavaOn a Windows system, start up EZJava

by selecting its icon on the desktop or the by selecting its icon on the desktop or the

menu item in the

menu item in the Start MenuStart Menu. The . The

application is also available from the "EZJava application is also available from the "EZJava

IDE" group in the

IDE" group in the All ProgramsAll Programs menu. menu.

On a Unix system, run the shell script named On a Unix system, run the shell script named ezjava in the installation directory.

ezjava in the installation directory.

On OS X, select the icon in the Applications On OS X, select the icon in the Applications folder.

folder.

(10)

Getting Started (continued)

Getting Started (continued)

(11)

Creating a Document Creating a Document

Use the Use the NewNew command to create a command to create a

document. In a dialog box, you can select document. In a dialog box, you can select

from five options.

from five options.

(12)

Creating a Document Creating a Document

(continued) (continued)

A source window is created in a tab pane. A source window is created in a tab pane.

For a console application, the document For a console application, the document

includes the public main application class includes the public main application class

DemoApplication and the main() method.

DemoApplication and the main() method.

The class name with the extension ".java"

The class name with the extension ".java"

is the default file name when you save the is the default file name when you save the

new document.

new document.

(13)

Creating a Document Creating a Document

(concluded)

(concluded)

(14)

Selected Menu Options Selected Menu Options

The menu bar includes familiar The menu bar includes familiar FileFile, , EditEdit, , Search

Search, , OptionsOptions, and , and WindowWindow items. The items. The RunRun, , DebugDebug, and , and ProjectProject items have items have

commands that organize and run the Java commands that organize and run the Java

program. Besides the usual editing program. Besides the usual editing

commands, EZJava has special options commands, EZJava has special options

that support the writing of Java source that support the writing of Java source

code.

code.

(15)

Selected Menu Options Selected Menu Options

(continued) (continued)

The The FileFile menu item presents the menu item presents the

standard file handling operations. In standard file handling operations. In

addition, a

addition, a RenameRename command enables you command enables you to change the name of an existing file.

to change the name of an existing file.

(16)

Selected Menu Options

Selected Menu Options

(continued)(continued)

The The EditEdit menu item contains menu item contains

A A Text UtilitiesText Utilities submenu that allows you to submenu that allows you to

uppercase, lowercase, or sentence case selected uppercase, lowercase, or sentence case selected

text.

text.

An option that allows you to convert between tabs An option that allows you to convert between tabs and blanks to align text in a source code file.

and blanks to align text in a source code file.

A Preferences item that allows the user to set the A Preferences item that allows the user to set the font, tab size, editor properties, printing properties, font, tab size, editor properties, printing properties,

compiler and runtime options, and the look and feel compiler and runtime options, and the look and feel

which includes

which includes MetalMetal, , MotifMotif as well as any look and as well as any look and feel unique to the system, such as

feel unique to the system, such as WindowsWindows. .

(17)

Selected Menu Options Selected Menu Options

(concluded) (concluded)

The The SearchSearch menu item contains standard menu item contains standard find/replace operations. In addition, a

find/replace operations. In addition, a Find Find in Files

in Files command allows you to recursively command allows you to recursively search within a directory and its

search within a directory and its

subdirectories for a word or phrase. The subdirectories for a word or phrase. The

command

command Go ToGo To <line number> is useful <line number> is useful when a runtime error message identifies when a runtime error message identifies

the statement (with line number) that is the statement (with line number) that is

(18)

Compiling and Running a Compiling and Running a

Program Program

After creating the source file, you must first After creating the source file, you must first compile it. The

compile it. The Compile Compile operation is a operation is a

command in the Run menu. You may also command in the Run menu. You may also

select an icon in the toolbar or use the select an icon in the toolbar or use the

keystroke command "Ctrl+K".

keystroke command "Ctrl+K".

A dialog box indicates whether any errors occur. If A dialog box indicates whether any errors occur. If so, the errors are listed in the Build window. When so, the errors are listed in the Build window. When you place the cursor over the file name in an error you place the cursor over the file name in an error message, it becomes the hand cursor. A single click message, it becomes the hand cursor. A single click

(19)

Compiling and Running a Compiling and Running a

Program (continued)

Program (continued)

(20)

Compiling and Running a Compiling and Running a

Program (continued) Program (continued)

The The RunRun command in the command in the RunRun menu menu

runs the program. You can also use an icon in runs the program. You can also use an icon in

the toolbar or the keystroke command the toolbar or the keystroke command

"Ctrl+R". Execution brings up a runtime

"Ctrl+R". Execution brings up a runtime window with a

window with a FileFile menu allowing you to print menu allowing you to print the text of the run and an

the text of the run and an EditEdit menu to copy menu to copy and paste selected text. Note that if the source and paste selected text. Note that if the source

file is modified and not recompiled, the Run file is modified and not recompiled, the Run

command with call the compiler and then command with call the compiler and then

(21)

Compiling and Running a Compiling and Running a

Program (concluded) Program (concluded)

// the "DemoApplication" class public class DemoApplication {

public static void main (String[] args) {

System.out.println("Running DemoApplication");

} }

(22)

Setting Class Paths Setting Class Paths

When converting a Java file toWhen converting a Java file to

bytecode, the compiler must locate all of the bytecode, the compiler must locate all of the external ".class" files that are referenced. To external ".class" files that are referenced. To

this end, the compiler uses a

this end, the compiler uses a class loaderclass loader. If . If the class is not a standard one, the loader the class is not a standard one, the loader

searches the

searches the classpathclasspath which defines a list of which defines a list of locations where class files are stored. EZJava locations where class files are stored. EZJava

automates creation of the classpath. In the automates creation of the classpath. In the

Run menu, select the

Run menu, select the Class PathsClass Paths option. option.

(23)

Setting Class Paths (concluded)

Setting Class Paths (concluded)

(24)

Using a Project Using a Project

In EZJava, a project is a mechanism for In EZJava, a project is a mechanism for compiling a collection of class and

compiling a collection of class and

interface files in a package structure, to interface files in a package structure, to

create a jar-archive of the files, and to create a jar-archive of the files, and to

create javadoc HTML documentation of create javadoc HTML documentation of

the files. The Project menu provides the the files. The Project menu provides the

necessary tools.

necessary tools.

(25)

Using a Project (continued)

Using a Project (continued)

(26)

Using a Project (continued) Using a Project (continued)

Begin by using the commandBegin by using the command New Project

New Project to create a new project in a to create a new project in a

directory. In the example, "ProjectName.prj"

directory. In the example, "ProjectName.prj"

is created in the directory ProjectDirectory.

is created in the directory ProjectDirectory.

(27)

Using a Project (continued) Using a Project (continued)

Use the Use the New PackageNew Package command to command to create a directory within the project create a directory within the project

directory. You can build the package with directory. You can build the package with

new or existing Java source code files for new or existing Java source code files for

classes and interfaces. Choose the

classes and interfaces. Choose the Main Main Class

Class menu item to associate a main menu item to associate a main application with the project.

application with the project.

(28)

Using a Project (continued) Using a Project (continued)

For a project, all of the ".java" files and For a project, all of the ".java" files and subdirectories (packages) are listed in a subdirectories (packages) are listed in a

hierarchy in the Open File view. The figure hierarchy in the Open File view. The figure

in the next slide illustrates a project with a in the next slide illustrates a project with a

main class "MainApplication.java" in the main class "MainApplication.java" in the

project directory and a package called project directory and a package called

"PackageName" containing classes and

"PackageName" containing classes and interfaces. Note that the main class can interfaces. Note that the main class can

(29)

Using a Project (continued)

Using a Project (continued)

(30)

Using a Project (continued) Using a Project (continued)

The The Make ProjectMake Project command compiles all of command compiles all of the Java files in the project directory and the Java files in the project directory and

in all subdirectories. This is a "smart in all subdirectories. This is a "smart

compile" in that only files which have been compile" in that only files which have been

modified since the last compile are modified since the last compile are

affected. The

affected. The Rebuild ProjectRebuild Project command command compiles all of the files in the project.

compiles all of the files in the project.

(31)

Using a Project (continued) Using a Project (continued)

When the When the Main ClassMain Class command is used to command is used to select a main class, the

select a main class, the Run ProjectRun Project command is operative. Like run for a command is operative. Like run for a

single program, the command creates a single program, the command creates a

runtime window which can be used for runtime window which can be used for

input and output.

input and output.

(32)

Using a Project (continued) Using a Project (continued)

The The UtilitiesUtilities submenu enables you to submenu enables you to create HTML documentation for the create HTML documentation for the

project, assuming you have placed project, assuming you have placed

javadoc comments in the source code.

javadoc comments in the source code.

The resulting HTML files are created in the The resulting HTML files are created in the

"docs" subdirectory of the project

"docs" subdirectory of the project

directory. The submenu also allows you directory. The submenu also allows you

(33)

Using a Project (continued) Using a Project (continued)

An example illustrates a project called An example illustrates a project called

"MeasurementProject.prj". The file

"MeasurementProject.prj". The file

"Measurement.java" specifies an interface, and

"Measurement.java" specifies an interface, and the files "Rectangle.java", "Circle.java" and

the files "Rectangle.java", "Circle.java" and

"Square.java" implement the interface. The

"Square.java" implement the interface. The interface and implementing classes are in the interface and implementing classes are in the

package "measurement". The Java file package "measurement". The Java file

"MeasurementDemo.java" is designated as the

"MeasurementDemo.java" is designated as the main class which becomes the starting point for main class which becomes the starting point for

the run of the project.

the run of the project.

(34)

Using a Project (continued)

Using a Project (continued)

(35)

Using a Project (continued) Using a Project (continued)

package measurement;

// the interface defines the static double PI and // the prototypes for measurement operations

public interface Measurement {

public static final double PI = Math.PI;

// return the area of the figure public double area();

// return the perimeter of the figure public double perimeter();

}

Measurement.java Measurement.java

(36)

Using a Project (continued) Using a Project (continued)

import measurement.*;

public class MeasurementDemo {

public static void main(String[] args) {

Measurement[] figure = { new Circle(5),

new Rectangle(3,5), new Square(2) };

for (int i=0;i < figure.length;i++)

System.out.println("Area = " + figure[i].area() +

(37)

Using a Project (concluded) Using a Project (concluded)

Run:

Area = 78.53981633974483 Perimeter = 31.41592653589793 Area = 15.0 Perimeter = 16.0

Area = 4.0 Perimeter = 8.0

Referensi

Dokumen terkait

Table 1: Basic elements of a generic project review framework  The gate review mechanism o Purpose of review o Timing of the gate review  Project governance o Independence of

Each mini project consisted of a slightly different task of: individual estimation for the project duration, group estimation of the project duration, and the actual group project