Ch 0 Lab: Metrowerks Java

Authors: Bronzell Dinkins
Trinity College, Hartford, CT
For use with Chapter 0

For Instructors

The purpose of this lab is to familiarize students with Metrowerks Codewarrior, the Integrated Development Environment (IDE) used to edit, compile, and run Java programs. This lab is designed to be done in conjunction with Chapter 1 of Java, Java, Java, 3E.

Objectives

The objectives of this lab are:

Before Lab

Read Chapter 1 of Java, Java, Java, 3E and read through this document. Bring your copy of the textbook to lab.

Editing, Compiling, and Running a Java Program

Metrowerks Codewarrior is an integrated development environment (IDE) for Java, C++, and other languages. It combines software resources for editing, compiling and running programs. In this IDE Java programs consist of two parts:
The Codewarrior project combines precompiled code from the Java class libraries with the code compiled from your Java source program, thereby increasing the functionality of your code. This lab will take you through the steps required to edit, compile, and run Java programs.

Step 0. Close all applications on your computer.

Close all applications that may be running on your computer in order to make as much memory as possible available to Codewarrior.

Step 1. Run the Metrowerks Codewarrior IDE

 Codewarrior IDE 4.0 is located in the Lab Applications folder.

  NOTE: Remember how to find this program because you're going to need it every week.

Step 2. Create the Lab1 project.

Once you have Codewarrior running, create a new project and configure it according to the following directions:

  • Click on the FILE menu option, then select NEW. Make sure the PROJECT tab is selected and enter the name of your project, "Lab1". The "Location" text box should indicate that your project will be stored on the desktop. In the project text area, double click on "JAVA Stationery". During this step, you should see something like the following window:
    Project Window

  • In the New Project window, click the "+" sign which is to the left of Java2. Select "Java Application" as the project type. During this step, you should see the following window:
    Project Window

  • After you save your project, Metrowerks will open a project window that should look something like this:

    Project Window

    If this is NOT how your project looks, ask for help.
  • Step 3. Run the TrivialApplication Program.

  • To compile and run TrivialApplication.java choose the Run option from the Project menu. Codewarrior will compile the application into Java bytecode and then interpret the bytecode all in one step. As a result, something like the following Java Output window should appear on your desktop.

    Project Window

  • Java programs are run by the Metrowerks Java program, which is an implementation of the Java Virtual Machine. It's a good idea to remove the Java Output window when the program is finished running. To do so, click on the "go-away box" (Upper left corner of the window's title bar).
  • Step 4. Edit and Re-Run TrivialApplication

    Lab Checkout

    There is nothing to hand in for this lab.

    You're done. Great work!