urgent help needed with source code for a matrix computation engine written in Java RMI
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   romeo_sarwar
Posted On:   Tuesday, November 12, 2002 03:26 AM

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, 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 HINTS: Details about matrix calculation rules can be found in the following websites: http://hilbert.dartmouth.edu/~m8s00/handouts/matrices3/node2.html http://hilbert.dartmouth.edu/~m8s00/handouts/matrices3/node3.html After much difficulty i managed to successfully generate working code for a standard calculator that subtracts, divides,   More>>


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,


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


HINTS: Details about matrix calculation rules can be found in the following websites:


http://hilbert.dartmouth.edu/~m8s00/handouts/matrices3/node2.html
http://hilbert.dartmouth.edu/~m8s00/handouts/matrices3/node3.html


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.


//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();
}
}




//The Calculator client program: CalculatorClient.java
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;

public class CalculatorClient {

public static void main(String[] args) {
try {
Calculator c = (Calculator)
Naming.lookup(
"rmi://localhost/CalculatorService");
System.out.println( c.sub(4, 3) );
System.out.println( c.add(4, 5) );
System.out.println( c.mul(3, 6) );
System.out.println( c.div(9, 3) );
}
catch (MalformedURLException murle) {
System.out.println();
System.out.println(
"MalformedURLException");
System.out.println(murle);
}
catch (RemoteException re) {
System.out.println();
System.out.println(
"RemoteException");
System.out.println(re);
}
catch (NotBoundException nbe) {
System.out.println();
System.out.println(
"NotBoundException");
System.out.println(nbe);
}
catch (
java.lang.ArithmeticException
ae) {
System.out.println();
System.out.println(
"java.lang.ArithmeticException");
System.out.println(ae);
}
}
}

   <<Less

Re: urgent help needed with source code for a matrix computation engine written in Java RMI

Posted By:   Christopher_Koenigsberg  
Posted On:   Tuesday, November 12, 2002 07:41 AM

Thanks for posting the URL of the assignment, so we can email your instructors about this, and see if they allow you to ask for outside help like this.

About | Sitemap | Contact