I need some help on an assignment on Java RMI (remote method invocation). I have been asked to generate a client, server, interface code for a matrix calculator, <p> The remote matrix computation engine should be able to do the following calculations: matrix multiplication, sum of two matrices, and the product of a scalar number and a matrix <p> HINTS: Details about matrix calculation rules can be found in the following websites: <p> http://hilbert.dartmouth.edu/~m8s00/handouts/matrices3/node2.html http://hilbert.dartmouth.edu/~m8s00/handouts/matrices3/node3.html <p> After much difficulty i managed to successfully generate working code for a standard calculator that subtracts, divides, adds and multiplies two integars,Can someone please help me from here, How can i modify this code so that it fits the role of a matrix computation engine. I have included the code below, Thanks in advance. <p>
<java> //Interface: Calculator.java
public interface Calculator extends java.rmi.Remote { public long add(long a, long b) throws java.rmi.RemoteException;
public long sub(long a, long b) throws java.rmi.RemoteException;
public long mul(long a, long b) throws java.rmi.RemoteException;
public long div(long a, long b) throws java.rmi.RemoteException; }
//The implementation of interface Calculator: CalculatorImpl.java
public class CalculatorImpl extends java.rmi.server.UnicastRemoteObject implements Calculator {
public CalculatorImpl() throws java.rmi.RemoteException { super(); }
public long add(long a, long b) throws java.rmi.RemoteException { return a + b; }
public long sub(long a, long b) throws java.rmi.RemoteException { return a - b; }
public long mul(long a, long b) throws java.rmi.RemoteException { return a * b; }
public long div(long a, long b) throws java.rmi.RemoteException { return a / b; } }
//The Calculator server program: CalculatorServer.java import java.rmi.Naming;
public class CalculatorServer {
public CalculatorServer() { try { Calculator c = new CalculatorImpl(); Naming.rebind("rmi://localhost:1099/CalculatorService", c); } catch (Exception e) { System.out.println("Trouble: " + e); } }
public static void main(String args[]) { new CalculatorServer(); } }