Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava.

Similar presentations


Presentation on theme: "© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava."— Presentation transcript:

1 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava IDE Bret Ford © 2005, Prentice Hall

2 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. EZJava EZJava is an Integrated Development Environment (IDE) that allows you to develop and run Java programs on a Windows, Linux, Solaris, or Macintosh OS X system. EZJava is an Integrated Development Environment (IDE) that allows you to develop and run Java programs on a Windows, Linux, Solaris, or Macintosh OS X system. Can select an appropriate look-and-feel for your system. Can select an appropriate look-and-feel for your system. Allows you to compile and run a main class along with any supporting classes in the same directory. Allows you to compile and run a main class along with any supporting classes in the same directory. Can create a project consisting of many source files within a package structure. Can create a project consisting of many source files within a package structure.

3 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. EZJava (continued) Can open multiple editing windows in tab panes, search a file hierarchy for a pattern that can include the use of regular expressions, and run programs with a debugger. Can open multiple editing windows in tab panes, search a file hierarchy for a pattern that can include the use of regular expressions, and run programs with a debugger. Editing and printer options allow you to set fonts and tabs, execute find/replace commands, and reformat text by replacing tabs with blanks and changing cases. Editing and printer options allow you to set fonts and tabs, execute find/replace commands, and reformat text by replacing tabs with blanks and changing cases. Provides options for automatically creating program documentation and for setting paths to the class and jar files required by applications. Provides options for automatically creating program documentation and for setting paths to the class and jar files required by applications.

4 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. EZJava (continued) New documents can be created using templates for console and GUI applications as well as applet programs and their associated HTML files. New documents can be created using templates for console and GUI applications as well as applet programs and their associated HTML files. An application executes in its own runtime window with a command button for multiple runs. An application executes in its own runtime window with a command button for multiple runs. Compiles Synchronous Java, which is an extension of Java with concurrent programming tools that are useful in an Operating Systems course. Compiles Synchronous Java, which is an extension of Java with concurrent programming tools that are useful in an Operating Systems course.

5 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Installation Install a version of Java SDK and create a PATH entry to the bin directory of the SDK. Install a version of Java SDK and create a PATH entry to the bin directory of the SDK. Download from www.EZJava.org. Download from www.EZJava.org.www.EZJava.org

6 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Installation (continued) Windows: After uncompressing the ZIP file Windows: After uncompressing the ZIP file Double-click the batch file EZJavaInstall.bat. This brings up a self ‑ explanatory GUI application that guides you through the installation. Double-click the batch file EZJavaInstall.bat. This brings up a self ‑ explanatory GUI application that guides you through the installation.

7 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Installation (continued) Unix: After uncompressing the ZIP file Unix: After uncompressing the ZIP file Change into the download directory and execute the command java -jar EZJavaInstaller.jar that runs the installer. Change into the download directory and execute the command java -jar EZJavaInstaller.jar that runs the installer.

8 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Installation (concluded) OS X: Run the dmg file to mount the installation volume. Drag the EZJava icon to the Applications folder. Also, please run the registration application. OS X: Run the dmg file to mount the installation volume. Drag the EZJava icon to the Applications folder. Also, please run the registration application.

9 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Getting Started On a Windows system, start up EZJava by selecting its icon on the desktop or the menu item in the Start Menu. The application is also available from the "EZJava IDE" group in the All Programs menu. On a Windows system, start up EZJava by selecting its icon on the desktop or the menu item in the Start Menu. The application is also available from the "EZJava IDE" group in the All Programs menu. On a Unix system, run the shell script named ezjava in the installation directory. On a Unix system, run the shell script named ezjava in the installation directory. On OS X, select the icon in the Applications folder. On OS X, select the icon in the Applications folder.

10 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Getting Started (continued)

11 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Creating a Document Use the New command to create a document. In a dialog box, you can select from five options. Use the New command to create a document. In a dialog box, you can select from five options.

12 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Creating a Document (continued) A source window is created in a tab pane. For a console application, the document includes the public main application class DemoApplication and the main() method. The class name with the extension ".java" is the default file name when you save the new document. A source window is created in a tab pane. For a console application, the document includes the public main application class DemoApplication and the main() method. The class name with the extension ".java" is the default file name when you save the new document.

13 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Creating a Document (concluded)

14 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Selected Menu Options The menu bar includes familiar File, Edit, Search, Options, and Window items. The Run, Debug, and Project items have commands that organize and run the Java program. Besides the usual editing commands, EZJava has special options that support the writing of Java source code. The menu bar includes familiar File, Edit, Search, Options, and Window items. The Run, Debug, and Project items have commands that organize and run the Java program. Besides the usual editing commands, EZJava has special options that support the writing of Java source code.

15 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Selected Menu Options (continued) The File menu item presents the standard file handling operations. In addition, a Rename command enables you to change the name of an existing file. The File menu item presents the standard file handling operations. In addition, a Rename command enables you to change the name of an existing file.

16 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Selected Menu Options (continued) The Edit menu item contains The Edit menu item contains A Text Utilities submenu that allows you to uppercase, lowercase, or sentence case selected text. A Text Utilities submenu that allows you to uppercase, lowercase, or sentence case selected text. An option that allows you to convert between tabs and blanks to align text in a source code file. An option that allows you to convert between tabs and blanks to align text in a source code file. A Preferences item that allows the user to set the font, tab size, editor properties, printing properties, compiler and runtime options, and the look and feel which includes Metal, Motif as well as any look and feel unique to the system, such as Windows. A Preferences item that allows the user to set the font, tab size, editor properties, printing properties, compiler and runtime options, and the look and feel which includes Metal, Motif as well as any look and feel unique to the system, such as Windows.

17 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Selected Menu Options (concluded) The Search menu item contains standard find/replace operations. In addition, a Find in Files command allows you to recursively search within a directory and its subdirectories for a word or phrase. The command Go To is useful when a runtime error message identifies the statement (with line number) that is the source of the problem. The Search menu item contains standard find/replace operations. In addition, a Find in Files command allows you to recursively search within a directory and its subdirectories for a word or phrase. The command Go To is useful when a runtime error message identifies the statement (with line number) that is the source of the problem.

18 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Compiling and Running a Program After creating the source file, you must first compile it. The Compile operation is a command in the Run menu. You may also select an icon in the toolbar or use the keystroke command "Ctrl+K". After creating the source file, you must first compile it. The Compile operation is a command in the Run menu. You may also select an icon in the toolbar or use the keystroke command "Ctrl+K". A dialog box indicates whether any errors occur. If so, the errors are listed in the Build window. When you place the cursor over the file name in an error message, it becomes the hand cursor. A single ‑ click causes the offending line to be selected. A dialog box indicates whether any errors occur. If so, the errors are listed in the Build window. When you place the cursor over the file name in an error message, it becomes the hand cursor. A single ‑ click causes the offending line to be selected.

19 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Compiling and Running a Program (continued)

20 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Compiling and Running a Program (continued) The Run command in the Run menu runs the program. You can also use an icon in the toolbar or the keystroke command "Ctrl+R". Execution brings up a runtime window with a File menu allowing you to print the text of the run and an Edit menu to copy and paste selected text. Note that if the source file is modified and not recompiled, the Run command with call the compiler and then execute the program. The Run command in the Run menu runs the program. You can also use an icon in the toolbar or the keystroke command "Ctrl+R". Execution brings up a runtime window with a File menu allowing you to print the text of the run and an Edit menu to copy and paste selected text. Note that if the source file is modified and not recompiled, the Run command with call the compiler and then execute the program.

21 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Compiling and Running a Program (concluded) // the "DemoApplication" class public class DemoApplication { public static void main (String[] args) { System.out.println("Running DemoApplication"); }

22 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Setting Class Paths When converting a Java file to bytecode, the compiler must locate all of the external ".class" files that are referenced. To this end, the compiler uses a class loader. If the class is not a standard one, the loader searches the classpath which defines a list of locations where class files are stored. EZJava automates creation of the classpath. In the Run menu, select the Class Paths option. When converting a Java file to bytecode, the compiler must locate all of the external ".class" files that are referenced. To this end, the compiler uses a class loader. If the class is not a standard one, the loader searches the classpath which defines a list of locations where class files are stored. EZJava automates creation of the classpath. In the Run menu, select the Class Paths option.

23 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Setting Class Paths (concluded)

24 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Using a Project In EZJava, a project is a mechanism for compiling a collection of class and interface files in a package structure, to create a jar-archive of the files, and to create javadoc HTML documentation of the files. The Project menu provides the necessary tools. In EZJava, a project is a mechanism for compiling a collection of class and interface files in a package structure, to create a jar-archive of the files, and to create javadoc HTML documentation of the files. The Project menu provides the necessary tools.

25 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Using a Project (continued)

26 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Using a Project (continued) Begin by using the command New Project to create a new project in a directory. In the example, "ProjectName.prj" is created in the directory ProjectDirectory. Begin by using the command New Project to create a new project in a directory. In the example, "ProjectName.prj" is created in the directory ProjectDirectory.

27 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Using a Project (continued) Use the New Package command to create a directory within the project directory. You can build the package with new or existing Java source code files for classes and interfaces. Choose the Main Class menu item to associate a main application with the project. Use the New Package command to create a directory within the project directory. You can build the package with new or existing Java source code files for classes and interfaces. Choose the Main Class menu item to associate a main application with the project.

28 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Using a Project (continued) For a project, all of the ".java" files and subdirectories (packages) are listed in a hierarchy in the Open File view. The figure in the next slide illustrates a project with a main class "MainApplication.java" in the project directory and a package called "PackageName" containing classes and interfaces. Note that the main class can also be within a package. For a project, all of the ".java" files and subdirectories (packages) are listed in a hierarchy in the Open File view. The figure in the next slide illustrates a project with a main class "MainApplication.java" in the project directory and a package called "PackageName" containing classes and interfaces. Note that the main class can also be within a package.

29 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Using a Project (continued)

30 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Using a Project (continued) The Make Project command compiles all of the Java files in the project directory and in all subdirectories. This is a "smart compile" in that only files which have been modified since the last compile are affected. The Rebuild Project command compiles all of the files in the project. The Make Project command compiles all of the Java files in the project directory and in all subdirectories. This is a "smart compile" in that only files which have been modified since the last compile are affected. The Rebuild Project command compiles all of the files in the project.

31 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Using a Project (continued) When the Main Class command is used to select a main class, the Run Project command is operative. Like run for a single program, the command creates a runtime window which can be used for input and output. When the Main Class command is used to select a main class, the Run Project command is operative. Like run for a single program, the command creates a runtime window which can be used for input and output.

32 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Using a Project (continued) The Utilities submenu enables you to create HTML documentation for the project, assuming you have placed javadoc comments in the source code. The resulting HTML files are created in the "docs" subdirectory of the project directory. The submenu also allows you create a "jar" file for the project class files. The Utilities submenu enables you to create HTML documentation for the project, assuming you have placed javadoc comments in the source code. The resulting HTML files are created in the "docs" subdirectory of the project directory. The submenu also allows you create a "jar" file for the project class files.

33 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Using a Project (continued) An example illustrates a project called "MeasurementProject.prj". The file "Measurement.java" specifies an interface, and the files "Rectangle.java", "Circle.java" and "Square.java" implement the interface. The interface and implementing classes are in the package "measurement". The Java file "MeasurementDemo.java" is designated as the main class which becomes the starting point for the run of the project. An example illustrates a project called "MeasurementProject.prj". The file "Measurement.java" specifies an interface, and the files "Rectangle.java", "Circle.java" and "Square.java" implement the interface. The interface and implementing classes are in the package "measurement". The Java file "MeasurementDemo.java" is designated as the main class which becomes the starting point for the run of the project.

34 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Using a Project (continued)

35 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. 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

36 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. 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() + " Perimeter = " + figure[i].perimeter()); }

37 © 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Using a Project (concluded) Run: Area = 78.53981633974483 Perimeter = 31.41592653589793 Area = 15.0 Perimeter = 16.0 Area = 4.0 Perimeter = 8.0


Download ppt "© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava."

Similar presentations


Ads by Google