Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 12th, 2002, 06:54 AM
romeo_2 romeo_2 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 2 romeo_2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Urgent Java RMI help needed

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:

URL
URL

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

Reply With Quote
  #2  
Old November 15th, 2002, 06:45 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Are you having trouble with any of the code itself, or just trying to figure out how to implement the Matrix calculations?
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Urgent Java RMI help needed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT