Extension Activity 3 – Compiling and running
the SimpleMessagesapplication
In this exercise you will compile the 3
Java source files that are needed to run the SimpleMessages application. You will then run the application.
(1) create a new, empty directory (folder) on your
computer’s hard disk called "Unit1Activity12".
(2) copy into this directory the following files from the
SimpleMessages application page:
MyShape.java
MyCircle.java
DrawShapes.java
(3) Compile these source files as follows with the
"javac" Java compiler:
javac
MyShape.java
javac MyCircle.java
javac DrawShapes.java
If you get any error messages after
entering a "javac" command, look up the problem in either the FAQ list or the "Debugging Java Programs"
list.
(4) Examine the list of files in this
directory (either by viewing a folder window, or the command line "dir"
command).
You should now have six files in your directory:
MyShape.java
MyCircle.java
DrawShapes.java
MyShape.class
MyCircle.class
DrawShapes.class
(5) Run the class containing the
"main()" method you wish to execute – in this case you need to run the
"DrawShapes" compiled class file.
java DrawShapes
(6) The "SimpleMessages"
application window should appear on screen as shown below.

Back
to top

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg
|