![]() |
java rmi error
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 |
Re: java rmi error
In article
<e19c97f8-4ed3-4041-aec6-34b6e7defd53@p25g2000hsf.googlegroups.com>, "shaunak.adgaonkar@gmail.com" <shaunak.adgaonkar@gmail.com> wrote: I have little experience with rmi, but it looks somewhat like you're following the Sun tutorial. I'll offer what help I can. Watch your code wrap and tabs. If it's easy to read and compile, more people are likely to look into the problem. [...] > Server code is : This looks more like a subinterface: <http://java.sun.com/docs/books/jls/t...erfaces.html#9. 1.3> > import java.rmi.*; > > public interface SampleServer extends Remote > { > public int sum(int a, int b) throws RemoteException; > } This compiles. > Client code is : [...] Your Client code is missing some trailing braces; it doesn't compile. > and interface code is : This looks more like a subclass that implements the subinterface you defined above. > import java.rmi.*; > import java.rmi.server.*; > import java.rmi.registry.*; > > public class SampleServerImpl extends UnicastRemoteObject > implements SampleServer [...] > javac SampleServerImpl.java gives me error like this > > SampleServerImpl.java : 6 Can not resolve symbol > > Symbol : class SampleServer Your SampleServerImpl compiles correctly for me, which prompts me to ask several questions: Do your file names match your class names? Does case matter on your operating system? Are there hidden characters in your file(s)? Is SampleServer.class in the current directory? Is the current directory on your classpath? > Please help me out guys -- John B. Matthews trashgod at gmail dot com home dot woh dot rr dot com slash jbmatthews |
| All times are GMT. The time now is 12:11 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.