Results 1 to 4 of 4
Thread: help for java rmi
- 03-13-2012, 06:14 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 5
- Rep Power
- 0
help for java rmi
Hi.
I wrote this program claculator java rmi.but not implemented.
you can help me?
Java Code:import java.rmi.Remote; import java.rmi.RemoteException; public interface calculator extends Remote { public long add(long a, long b) throws RemoteException; public long sub(long a, long b) throws RemoteException; public long mul(long a, long b) throws RemoteException; public long div(long a, long b) throws RemoteException; }Java Code:import java.rmi.Naming; import java.rmi.RemoteException; import java.rmi.RMISecurityManager; import java.rmi.server.UnicastRemoteObject; public class calculatorServer extends UnicastRemoteObject implements calculator { public calculatorServer () throws RemoteException { super(); } public long add(long a, long b) { return a + b; } public long sub(long a, long b) { return a * b; } public long mul(long a, long b) { return a - b; } public long div(long a, long b) { return a / b; } public static void main(String args[]) { try { Calculatorserver clapton = new Calculatorserver(); Naming.rebind("rmi://localhost:1099/CalculatorService", clapton); } catch (Exception e) { System.out.println("Trouble: " + e); } } }Java Code:import java.rmi.Naming; import java.rmi.RemoteException; public class CalculatorClient { public static void main(String[] args) { try { Calculator clapton = (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 (Exception e) { System.out.println("Trouble: " + e); } } }
- 03-13-2012, 06:17 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
Re: help for java rmi
Help with what exactly?
Please do not ask for code as refusal often offends.
- 03-13-2012, 06:24 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 5
- Rep Power
- 0
Re: help for java rmi
i can't run this program.it is not work.you can run this program?
- 03-14-2012, 09:44 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks