![](head.gif)
Java Directions
Intro
This page is to help you get java working. There are many ways to make java
programs, so if you have a compiler that works for you then feel free to use
that. But for people who do not know how to compile java programs, read on.
Get the files
First you must download the files. Go to
the homework page and then continue to your individual
page. After your page loads, go up to the file menu and save your web page
(save as source) into a new directory - let's assume it's called "homework".
Then select the "source code" link at the bottom of your page to continue
to your code directory. From this directory, download mas110panel.java and
save it in a directory called "code" that is inside of "homework". Then also
download and save mas110runner.java and yourname_ps3_p1.java through
yourname_ps3_p5.java, saving all files inside of the "code" subdirectory.
Compile, debug
these java files, which depends on your platform. I'm going to explain how this
works for Athena, and mention how to do this on your own machine. If you have
problems doing this on your machine, I suggest you use Athena instead. If you
do not have and Athena account, please let Jared know as he knows the process
for obtaining one.
On an athena machine, log in and type the following:
add java
Now go into the "homework" and "code" directory from above, and type the following:
javac *.java
this will compile all of the java files into class files, which can be run by
a web browser like Netscape. Do not worry about deprecated warnings.
So now you should be able to open your html file
from above (which is in the homework dirctory) and see your applets running,
but your applet will be running the default test pattern.
To make your first applet run your own program, open up youname_ps3_p1.java in
a text editor like vi or emacs. There should be a function called draw which
looks like this:
public void draw(Graphics g, float t) {
super.draw(g, t);
g.setColor(Color.red.darker());
g.drawString("" + this.getClass().getName(), 5, h/2);
}
Remove the three lines between the braces and replace it with your own code. For
example:
public void draw(Graphics g, float t) {
g.setColor(new Color(0.5f, 0.5f, 0.5f));
g.fillRect(0,0,w,h);
}
Now, from the code directory, type:
javac yourname_ps3_p1.java
This will make a new yourname_ps3_p1.class file. To see this program run, either
go back into Netscape and hit [Shift]+Reload to cause the applet to reload from
the disk as opposed to the cache. Or you can use appletviewer from the homework
directory - just type 'appletviewer yourfile.html' to load your applet in its
own window.
Windows Sidebar
This process is very similar if you are running on your own Windows based computer,
but you must install the jdk from sun. Go to the download page at
sun's java site, I recommend
version 1.2 for Windows, download, and install the JDK. Then follow
the instructions as above, using a DOS window instead of an Athena shell.
You will also need a text editor, but you can use the Notepad application,
which is generally found on all Windows computers.
Upload your solutions
Once you have your solutions, you are ready to upload them back to the
server. Go back to the homework page, but now
go down to the upload links and choose your name. This will put you
into your upload area. You need to upload 10 files, yourname_ps3_p1.java
through yourname_ps3_p5.java, and the corresponding class files.
Make sure you upload both the java and class files.
There are two ways to upload files. One is to drag and drop the files
from your operating system onto the Netscape window. This is quite
handy, but may not work on all computers. So the other way is to go to
the File menu and choose "Upload File...", and then select the
file you want to upload to our server.
Once your files are uploaded, you should see your java programs update
on your homework page right away. In class we will be using a special
version of the program, not the debug viewer you are using, so
that we can more easily see everyone's solution.