Java rmi-Ps help.its urgent!!!
I've tried to run the BankServer.java class for several hours and this is the error it gives me:
G:\Distributed Objects\Exercise 3\BankServer.java:11: cannot find symbol
symbol : constructor BankImpl()
location: class BankImpl
BankImpl b = new BankImpl();
I have other classes orf the Bank interface, BankImpl and BankClient but they're all working fine. I've tried to add a no-argument constructor to BankImpl, or change the way I'm calling it to match one of the declared constructors but it stil wont work. here are all of the classes.ps help.
//Bank.java
//RMI interface.
import java.rmi.*;
publicinterface Bankextends Remote
{
publicint getAcctNum()throws RemoteException;
public String getName()throws RemoteException;
publicdouble getBalance()throws RemoteException;
publicdouble withdraw(double amount)throws RemoteException;
publicvoid deposit(double amount)throws RemoteException;
}
//BankImpl.java
//Implementation of RMI interface.
import java.rmi.*;
import java.rmi.server.*;
publicclass BankImplimplements Bank
{
privateint accountNumber;
private String lastName;
private String firstName;
privatedouble balance;
public BankImpl (int acctNo, String lname, String fname,double bal)
{
accountNumber = acctNo;
lastName = lname;
firstName = fname;
balance = bal;
}
publicint getAcctNum()throws RemoteException
{
return accountNumber;
}
public String getName()throws RemoteException
{
return (firstName +" " + lastName);
}
publicdouble getBalance()throws RemoteException
{
return balance;
}
publicdouble withdraw(double amount)throws RemoteException
{
if (amount <= balance)return amount;
elsereturn 0;
}
publicvoid deposit(double amount)throws RemoteException
{
if (amount > 0) balance += amount;
}
}
//BankClient.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
publicclass BankClient
{
privatestaticfinalint[] acctNo ={111111, 222222, 333333, 444444};
publicstaticvoid main(String args[])
{
try{
//get remote objectreference (stub)
Registry registry = LocateRegistry.getRegistry("Localhost");
Bank b = (Bank)registry.lookup("BankService");
for (int i=0; i<acctNo.length; i++)
{
System.out.println("\nAccount number: " + b.getAcctNum());
System.out.println("Name: " + b.getName());
System.out.println("Balance: " + b.getBalance());
}
}catch (java.rmi.RemoteException re){
System.out.println("RemoteException");
System.out.println(re);
}
catch (java.rmi.NotBoundException nbe){
System.out.println("NotBoundException");
System.out.println(nbe);
}
catch (java.lang.ArithmeticException ae){
System.out.println("java.lang.ArithmeticException");
System.out.println(ae);
}
}
}
//BankServer.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
publicclass BankServer
{
publicstaticvoid main(String[] args)throws Exception
{
try{
BankImpl b =new BankImpl();
//'0' denotes location where exported object 'c' is to be stored
Bank stub = (Bank)UnicastRemoteObject.exportObject(b,0);
Registry registry = LocateRegistry.getRegistry();
registry.rebind("BankService", stub);
System.out.println("Bank server running");
BankImpl[] account =
{new BankImpl(111111,"Smith","James", 112.58),
new BankImpl(222222,"Jones","Sally", 507.85),
new BankImpl(333333,"White","Mary Jane", 2345.00),
new BankImpl(444444,"Brooks","Mark", 10028.00)};
for (int i=0; i><account.length; i++)
{
int accountNumber= account[i].getAcctNum();
}
}catch(Exception e){
System.out.println("Trouble: " + e);
}
}
}
>

