Using Java with Metrowerks CodeWarrior 6.0/6 · Using CodeWarrior for Java is much the same as for...
Transcript of Using Java with Metrowerks CodeWarrior 6.0/6 · Using CodeWarrior for Java is much the same as for...
Using Java with Metrowerks CodeWarrior 6.0/6.1Ryan Thomson June 12, 2001
This document specifies the procedure for creating and setting up
Metrowerks CodeWarrior 6.0/6.1 for Java development. It is
suggested that the newest JDK (Java Development Kit) from Sun
Microsystems is used. At the time of this writing the current release
of the Sun JDK is Java 2 1 .3.
Using CodeWarrior for Java is much the same as for C++. To begin, startup
CodeWarrior and wait for the familiar greeting of the CodeWarrior menu:
You should first create your main Java file containing the source code of your
java program before beginning with a project. To accomplish this, select � File-
>New & � from the File menu.
This will bring a dialog box requesting the project o r file type you wish to
create. Click the � File � tab and select text file.
Type a name and location for your new Java file and click ok. Be sure that the
extension you are using is �.java � . This will bring up an empty text-editing
window.
Start with a simple java application such as � Howdy Partner! � . Type the
following code into the editor windows. Notice that the name of your class,
� Howdy � must later be the name of your � Java Target � . This will be further
explained further at the end of the handout.
You should now save the file by selecting, � File->Save � .
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
To create a new Java Console Application project, select � File->New & � from
the File menu.
This will bring up the project stationery for various projects styles and
programming languages. Choose � Java Stationery � then enter a project name
and directory.
After you have chosen a proper name and directory for your project, click the
� Ok � button to continue. This will bring up a box asking you for version type
of program you wish to create. Choose � JDK 1.3 ->Java Application � :
This will finalize the project selection phase and bring up the project window.
To remove the default file � TrivialApplication.java � , open the � Source �
directory. Then right click on � TrivialApplication.java � and select �Delete � .
After selecting � Delete � from the menu, you will be asked if you are sure you
want to de lete � TrivialApplication.java � from the project. Click � Ok � to
remove the file.
Next you want to add your Java source files to the project. Do this by selecting
the � Sources � directory in the project dialog box and clicking � Add files � from
the Project menu:
This selection will bring up a dialog box very similar to the standard �Open �
dialog box you see very often when using windows. Locate the Java file you
created at the start of this hand out and click � Add � :
This will add your Java file to the project.
To finalize your project, you must follow the next few steps so that the Java
Virtual Machine will run your code properly.
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
An Important Note about Java with CodeWarrior
When changing the name of the main class (class containing the
public static void main() function) you must also indicate this change
in the project settings dialog box. This option specifies which class is
the main class. This option must be specified as such for the project
to compile and run properly.
To open the project settings dialog box, click the � Targets � tab on
the project window. This will bring up two icons. One is labeled
� Java Application Release � and the other is labeled � Java
Application Debug � .
To access the project settings dialog box, double click on � Java
Application Release � . This will bring up the dialog box where you
will need to specify the change of the main class name.
To change the Java target settings, click on � Java Target � under the
Target Settings Panel to bring up the property sheet dealing with
target settings (including the option for specifying main class name).
The text field labeled � Main Class: � should now be changed the to
new name of the main class. It is important to note that Java and
CodeWarrior are both case sensitive. Any capitalization in the class
name must be identically copied to the text field.
Once this is complete, click Ok and repeat the process for � Java
Application Debug � in the project � Targets � tab.
You should now be able to compile and run your Java program with
a new main class name.
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ