View Single Post
  #1 (permalink)  
Old 12-07-2007, 01:16 AM
Robbinz Robbinz is offline
Member
 
Join Date: Dec 2007
Posts: 4
Robbinz is on a distinguished road
RMI naming problem
Ok heres the story.

Im writing a banking system in RMI. Im new to Java and am not very strong in programming. Ive designed my program (I think) but im having a problem.

Im having problems binding my server object to the object in the client. Im not sure how to do it?

Can someone help?

import java.rmi.Naming;

//import bankInterface;

// This program tries out some of the methods in the BankingImpl
// remote object.

public class BankClient
{

public static void main(String args[])
{



// Create an Account object for the account we are going to access.

Account myAccount = new Account("steve", "1111");

try {

// Get a stub for the BankingImpl object (the stub implements the
// Banking interface).

BankInterface bank = (BankInterface)Naming.lookup(MyBank);

System.out.println("My balance is: "+
bank.balance(myAccount));

bank.deposit(myAccount, 50000);

System.out.println("Deposited $500.00, balance is: "+
bank.balance(myAccount));

bank.withdrawal(myAccount, 25000);

System.out.println("Withdrew $250.00, balance is: "+
bank.balance(myAccount));

} catch (Exception e) {
System.out.println("Got exception: "+e);
e.printStackTrace();
}
}
}

Its the code in the red. My server name is MyBank.
Any help would be greatly appretiated thanks.
Reply With Quote
Sponsored Links