JAVA Calculator Tutorial
Clay Gloster/Mustafa Dagtekin
Discussion
Java Calculator is a proof-of-concept demonstration that performs these functions:
The addition of two signed 32-bit integers ( range: -32,766 to 32,767),
the subtraction of two integers and the multiplication of two numbers.
The user can choose to do this locally or
remotely with standard software methods including Java and C methods. The remote and local
hardware methods are not implemented yet.
If the user chooses to add locally, a simple java statement is executed
to perform the operations using C native methods or Java methods.
If a remote operation is chosen, things get a bit more
complex: the java Calculator client uses the network to ask a JAVA server to
execute, on its behalf, a method which takes the two integers as parameters and
calls either Java method or C native method.
Download Source Files
Click here to download a zip file of the:
You will also need the Java
Development Kit
Compiling and running the demo
Read the text file "readme.txt" in the distribution, or see below
in Starting the system for instructions.
The JAVA Client
The client is the portion of the system visible to the user. It is a simple
interface that allows for entry of operands, selecting necessary functions,
display of various messages,
and range/error checking. In the example below, the client is using the
"bowlingball" server.
The interface was constructed using the JDK 1.1.5 AWT.
The first row is used to select operation type: addition, subtraction, or
multiplication
The second row is to select either native methods(C) or Java methods to
perform the operation. A hardware button is also presented but has not been implemented yet
The third row is to select either remote operations or local operations..
The JAVA Server
Ther server is a console application that provides indications of its activities.
In the example below, both server and client are running on "bowlingball"
The server was implemented using the JDK 1.1.5.
Starting the system
A makefile is provided to make things easier. You can examine the makefile
and see what is going on inside.
-
To make and run the system use "make HOSTNAME=your_machines_hostname"
- "make compile" only makes the system
- "make run" only runs the system
- "make run_clientonly" only runs the client
- "make run_serveronly" only runs the server
Example:
% cd Calculator
% make HOSTNAME=bowlingball.cacc.ncsu.edu
If you want to exit the system, use ctrl-c to close rmiregistry and server
program, and use "Quit" to close the client.
|