S
shaunak.adgaonkar
have already compiled server file it gets compiled but when i try to
compile my interface and client it gives me error that my server class
is not found or can not resolve the symbol... let me give u the
code .... any help is appreciated..
Server code is :
import java.rmi.*;
public interface SampleServer extends Remote
{
public int sum(int a,int b) throws RemoteException;
}
Client code is :
import java.rmi.*;
import java.rmi.server.*;
public class SampleClient
{
public static void main(String[] args)
{
// set the security manager for the client
System.setSecurityManager(new RMISecurityManager());
//get the remote object from the registry
try
{
System.out.println("Security Manager loaded");
String url = "//localhost/SAMPLE-SERVER";
SampleServer remoteObject =
(SampleServer)Naming.lookup(url);
System.out.println("Got remote object");
//narrow the object down to a specific one
//System.out.println("Location: " +
System.getProperty("LOCATION"));
// make the invocation
System.out.println(" 1 + 2 = " +
remoteObject.sum(1,2) );
}
catch (RemoteException exc)
{
System.out.println("Error in lookup: " + exc.toString());
}
catch (java.net.MalformedURLException exc)
{
System.out.println("Malformed URL: " + exc.toString());
}
catch (java.rmi.NotBoundException exc)
{
System.out.println("NotBound: " + exc.toString());
}
and interface code is :
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
public class SampleServerImpl extends UnicastRemoteObject
implements SampleServer
{
SampleServerImpl() throws RemoteException
{
super();
}
public int sum(int a,int b) throws RemoteException
{
return a + b;
}
public static void main(String args[])
{
//set the security manager
try
{
System.setSecurityManager(new RMISecurityManager());
//create a local instance of the object
SampleServerImpl Server = new SampleServerImpl();
//put the local instance in the registry
Naming.rebind("SAMPLE-SERVER" , Server);
System.out.println("Server waiting.....");
}
catch (java.net.MalformedURLException me)
{
System.out.println("Malformed URL: " + me.toString());
}
catch (RemoteException re)
{
System.out.println("Remote exception: " + re.toString());
}
}
}
Now i use this
javac SampleServer.java .... it gets compiled
but when i use
javac SampleServerImpl.java it gives me error like this
SampleServerImpl.java : 6 Can not resolve symbol
Symbol : class SampleServer
Please help me out guys
compile my interface and client it gives me error that my server class
is not found or can not resolve the symbol... let me give u the
code .... any help is appreciated..
Server code is :
import java.rmi.*;
public interface SampleServer extends Remote
{
public int sum(int a,int b) throws RemoteException;
}
Client code is :
import java.rmi.*;
import java.rmi.server.*;
public class SampleClient
{
public static void main(String[] args)
{
// set the security manager for the client
System.setSecurityManager(new RMISecurityManager());
//get the remote object from the registry
try
{
System.out.println("Security Manager loaded");
String url = "//localhost/SAMPLE-SERVER";
SampleServer remoteObject =
(SampleServer)Naming.lookup(url);
System.out.println("Got remote object");
//narrow the object down to a specific one
//System.out.println("Location: " +
System.getProperty("LOCATION"));
// make the invocation
System.out.println(" 1 + 2 = " +
remoteObject.sum(1,2) );
}
catch (RemoteException exc)
{
System.out.println("Error in lookup: " + exc.toString());
}
catch (java.net.MalformedURLException exc)
{
System.out.println("Malformed URL: " + exc.toString());
}
catch (java.rmi.NotBoundException exc)
{
System.out.println("NotBound: " + exc.toString());
}
and interface code is :
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
public class SampleServerImpl extends UnicastRemoteObject
implements SampleServer
{
SampleServerImpl() throws RemoteException
{
super();
}
public int sum(int a,int b) throws RemoteException
{
return a + b;
}
public static void main(String args[])
{
//set the security manager
try
{
System.setSecurityManager(new RMISecurityManager());
//create a local instance of the object
SampleServerImpl Server = new SampleServerImpl();
//put the local instance in the registry
Naming.rebind("SAMPLE-SERVER" , Server);
System.out.println("Server waiting.....");
}
catch (java.net.MalformedURLException me)
{
System.out.println("Malformed URL: " + me.toString());
}
catch (RemoteException re)
{
System.out.println("Remote exception: " + re.toString());
}
}
}
Now i use this
javac SampleServer.java .... it gets compiled
but when i use
javac SampleServerImpl.java it gives me error like this
SampleServerImpl.java : 6 Can not resolve symbol
Symbol : class SampleServer
Please help me out guys