wood burning stoves 2.0*
The moose likes Distributed Java and the fly likes compilation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "compilation error" Watch "compilation error" New topic
Author

compilation error

srikanth arroju
Ranch Hand

Joined: Aug 02, 2006
Posts: 66
iam compiling a sample rmi program on the same machine the program consists
three clases
import java.rmi.*;
public interface Calc extends Remote
{
public int add(int i,int j)throws RemoteException;
}


import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;

public class CalcImpl extends UnicastRemoteObject implements Calc
{
public CalcImpl()throws RemoteException
{
super();
}

public int add(int i,int j)throws RemoteException
{
return i+j;
}

public static void main(String[] args)throws Exception
{
CalcImpl ci=new CalcImpl();
RemoteRef ref=ci.getRef();
CalcClient cc=new CalcClient(ref);
}
}


import java.rmi.server.*;
import java.rmi.*;

public class CalcClient
{
public CalcClient(RemoteRef ref)throws RemoteException
{
CalcImpl_Stub stub=new CalcImpl_Stub(ref);
System.out.println(stub.add(3,4));
}
}

iam getting error in calcClient class
CalcClient.java:8: cannot find symbol
symbol : class CalcImpl_Stub
location: class CalcClient
CalcImpl_Stub stub=new CalcImpl_Stub(ref);
^
CalcClient.java:8: cannot find symbol
symbol : class CalcImpl_Stub
location: class CalcClient
CalcImpl_Stub stub=new CalcImpl_Stub(ref);
^
CalcImpl.java:19: cannot find symbol
symbol : class RemoteRef
location: class CalcImpl
RemoteRef ref=ci.getRef();
^
chandra garre
Greenhorn

Joined: Nov 08, 2005
Posts: 7
1. RemoteRef error you are getting in CalcImpl since it doesnt import java.rmi.server.RemoteRef
2. You never use stub like this, you will typically have an rmiregistry that has registered this, and then you would call registry.lookup() method and typecast to Calc and then call add() on it. Stub etc are used internally by RMI to call appropriately.

See this reference for a good tutorial http://java.sun.com/docs/books/tutorial/rmi/overview.html

Hope this helps. Happy RMI' ing :-)

Chandra Garre
 
Consider Paul's rocket mass heater.
 
subject: compilation error
 
Similar Threads
Help with CalcHome.java interface
Why is it giving "package does not exist error"
Problems with Java RMI
Help with CalcHome.java interface
want to integrate RMI with application on Client machine