CE00371-1 INTRODUCTION TO SOFTWARE DEVELOPMENT


IDE Lab

Assessment weight : 3%

Due : Week 3

Introduction

An integrated development environment (IDE) is a programming environment that has been packaged as an application program, typically consisting of an language senstive editor, a compiler, a debugger, and a graphical user interface (GUI) builder. Eclipse is a universal tool platform which included in its java development tools subproject, a Java IDE supporting the development of any Java application. The functionality of Eclipse can be extended with plug-ins such as UML plug-ins for Object-Oriented modeling. You can learn more about Eclipse project and download the latest version of Eclipise from eclipse.org

For this exercise, we will show you how to perform different tasks using Eclipse.

  1. Download and install Eclipise for the Windows platform.
  2. Creat a working directory lab11 and download the following files for this lab:

  3. Create the Project

    Select the menu item File > New > Project.... to open the New Project wizard

    On the left pane of the first wizard page, select Java, and on the right pane, select Java Project. Then click Next. On the next page, type "lab11" in the Project name field and click Finish. A Java perspective opens inside the workbench with the new Java project in the Package Explorer. When the Java perspective is active, new menu options and Java specific buttons are loaded in the workbench toolbar. Depending on which view or editor is active, other buttons and menu options will be available.

  4. Import classes into the project

    In the Package Explorer, make sure that the lab11 project is selected. Select the menu item File > Import....

    Select File system, then click Next.

    In the Import wizard, below the hierarchy list click Select All. You can expand and select elements within the lab11 directory on the left pane to view the individual resources that you are importing on the right pane.

    Click Finish to finish the import.

  5. Using the Java Editor

    You can open TaiChiApplet or any file in the project default package by double clicking on it. In general you can open a Java editor for Java files, types, methods and fields by simply double clicking on them. For example, to open the editor directly on the draw() method defined in TaiChi.java, double click on the method in the Package Explorer or Outline view window. Notice the syntax highlighting. Different kinds of elements in the java source are rendered in unique colors. Examples of java source elements that are rendered differently are:

    Regular comments
    Javadoc comments
    Keywords
    Strings.

  6. Running an applet

    In the Package Explorer view, find TaiChiApplet.java and double-click it to open it in an editor. Select the Window menu Show view item, click Outline view to open the Outline view window. Look at the Outline view. It displays an outline of the Java file including the package declaration, import declarations, fields, types and methods. The Outline view uses icons to annotate Java elements. For example, icons indicate whether a Java element is static, abstract, or final. Different icons show you whether a method is overridden from a base class ( ) or when it implements a method from an interface ( ).

  7. Using the drop-down Run button in the toolbar, select Java Applet from the cascading Run As menu. This will launch the class in the active editor, or the selected class in the Navigator, as a Java applet.

  8. Creating a new Java class NewTaiChiApplet

    In the Package Explorer view, select the default package of lab11 project and click the Create a Java Class button in the toolbar. Make sure that lab11 appears in the Source Folder field and that nothing appears in the Package field. In the Name field, type NewTaiChiApplet.

  9. Click the Browse button next to the Superclass field.

    In the Choose a type field in the Superclass Selection dialog, type App to narrow the list of available superclasses.

    Select the Applet class and click OK. Uncheck all checkbox under "Which method studs would you like to create?" group. Click Finish to create the new class.

  10. The new file is opened in the editor. It contains the new class, and comments. Finish the program to create a new TaiChi diagram with different color. Save and run the applet to see your output.



  11. Adding new methods

    Select the file Rational.java, start adding the following at the end of the Rational.java file.

    
     public Rational divide(Rational  rhs)  {
      return  new  Rational(numerator * rhs.denominator,
    			   this.denominator * rhs.numerator);
     }
    
    As soon as you type the method name in the editor area, the new method appears at the bottom of the Outline view.

  12. Try erasing the last "}" in your file and click the Save button to save your work. An error annotation (red square) appears in the overview ruler positioned on the right hand side of the editor. In the Package Explorer view, the errors are propagated up to the project of the compilation unit containing the error. This error annotation indicates that the compilation unit is currently not correct. If you hover over the red square a tool tip appears, Unmatched bracket; Syntax error on token "}", "{" expected, which is correct in this case. Note that error annotations in the editor's rulers are updated as you type.

    Correct the error and save the file. Notice that the error indicators disappear since the missing bracket has been added.

  13. Running an apllication

    In the Package Explorer view, find RationalDriver.java and double-click it to open it in an editor.

    In the Outline view, notice that the RationalDriver class has an icon which indicates that the class defines a main method.

    Using the drop-down Run button in the toolbar, select Java Application from the cascading Run As menu. This will launch the class in the active editor, or the selected class in the Navigator, as a local Java application.

    Notice that the program has finished running and in addition to the pop-up windows, an error message appears in the Console view telling you that the program encounters a java.lang.ArrayIndexOutOfBoundsException.

  14. Running a program as a Java Application uses the default settings for launching the selected class and does not allow you to specify any arguments.

    Since RationalDriver class uses arguments from main() method as input. To specify arguments, use the drop-down Run menu in the toolbar and select Run....
    This time, the Launch Configurations dialog opens with the RationalDriver launch configuration selected. A launch configuration allows you to configure how a program is launched, including its arguments, classpath, and other options.

  15. Select the Arguments tab and type 1 2 3 4 in the Program arguments area. Click Run. This time the program runs correctly.