Writing a Java program with networking
The goal of the project is to write an Java applet or application that
communicates via networking. It will also include the language and user
interface parts of Java that you have already learned.
You should design an original program. Examples of the kind of programs
that you can write are:
-
A one-person game applet. The user can play the game, give a name and have
their score saved on the "high-scores list". This is stored in a file on
the web host machine. The applet can connect to a CGI script to write the
high-scores file, or connect to a Java application server. The user should
also be able to view the high-scores, so the applet must also read and
format this file.
-
A two-person game application server with client applets for each player.
An example of this can be found in the Deitel book, where there is a tic-tac-toe
game server. Two people can play the game through applets. Sockets are
used for the applets to communicate with the game server. (Of course, your
game server must be different than this one.)
-
A chat or other collaboration server. The application server keeps track
of who is signed in to the session, keeps all messages and whenever a user
types in a message, broadcasts it to the other people.
If you choose to do a text-based chat, you should implement the
standard features of signing in to a chat session, displaying the names
of all the people currently logged in to the session, and displaying all
the messages. In addition, you should do some additional features (how
much depends on whether you're working alone or in a group of two). Additional
features could include the capability of subgroups, so that not everyone
sees every message; saving the chat session to a file so that you can read
the messages later; or only allowing people to login who are validated
for the chat (in a separate interface).
Another type of collaboratory server is a whiteboard, where two or more
people can draw on the canvas and see each other's drawings.
Another idea is a collaboratory spreadsheet, described in this
Shared Spreadsheet project from another university (ignoring references
to C++ and Playground).
-
A traditional business model server such as an airline reservation system.
There would be an application server that kept files with airplane flight
schedules and who has made reservations for each flight. The client applets
could request flight information and make a reservation for a particular
flight.
-
A distributed computation running on multiple Java applications. Suppose
that you have a large computation that run as a parallel program either
by decomposing the problem into a set of programs or by decomposing the
problem by running the same program on separate pieces of data. You can
run this problem in a collection of Java applications and view the results
in another application or applet that all communicate with sockets. As
an example of the latter type of problem, suppose that we want to run a
large game of life. In this game, there is a 2-D array representing space.
Some cells are occupied by people. The game starts in an initial configuration
and a loop steps through time. At each time step, a set of rules based
on the contents of the neighboring cells determines if, in that cell, a
person is born, keeps living, or dies. For distributed computing, each
of the several Java applications will compute the game of life on a portion
of the whole space. These applications must communicate part of their space
to each other at each time step. Links with the details of Life will be
forthcoming. If you know how to do some other problem via parallel computing
and want to implement it in Java in this fashion, please send me email.
(This is one of the subjects of the course CPS615.)
For some other ideas, check out this Syrup
Factory Process Control project from another university (ignoring references
to C++ and Playground), and design a Java application to be the factory,
another to be the control, and an application or applet to visualize the
process.
Several of the above ideas could be implemented using RMI instead of Sockets.
If you do use RMI, you should pick a port number between 1024 and 9999.
This is the port that you will run your name registry:
rmiregistry xxxx &
where xxxx is your port number. If someone else is already using that
number, you'll get a message and can pick a new one.
This port number also needs to be put into two files. In HelloImpl.java,
change the port name in the registry:
Naming.rebind("//osprey7.npac.syr.edu:xxxx/DBCServer", obj);
In the file HelloApplet.java, similarly add the port number ":nnnn/HelloServer"
in the argument to Naming.lookup.
There are many examples of these types of programs on the web and from
previous classes. If you use one of these examples as a starting point,
please be very careful to include a significant portion of original work
and to include this description in your project report. Also please be
sure that your program is written in JDK1.1 unless you describe a particular
reason why you want it in JDK1.0.
If you want to design a project different from the topics listed above,
please send an email request. Exceptions may be given if you have an idea
of something else that would be particularly useful in your job or your
research projects.
For your homeworks, you have been asked to write a description of your
problem; for the project we will call this a Project Report. Since you
will all be writing different programs, please be careful to write a detailed
description of the problem, your program and its behavior. The Project
Report should be written as an html page, and should be nicely formatted
with headings and so on.
For the project, you may choose whether to work individually or to work
in a group of two people. If you work in a group, the Project Report should
state which parts of the project each person did.