Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compilation error

 
srikanth arroju
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic