java rmi error

Discussion in 'Java' started by shaunak.adgaonkar@gmail.com, Jul 6, 2008.

  1. Guest

    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
    , Jul 6, 2008
    #1
    1. Advertising

  2. In article
    <>,
    "" <> 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/third_edition/html/interfaces.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
    John B. Matthews, Jul 7, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vnssoftware
    Replies:
    0
    Views:
    441
    vnssoftware
    Aug 12, 2004
  2. Buu Nguyen

    RMI, JINI or RMI/IIOP

    Buu Nguyen, Aug 25, 2004, in forum: Java
    Replies:
    1
    Views:
    561
    Sudsy
    Aug 25, 2004
  3. JScoobyCed

    RMI Vs RMI over IIOP

    JScoobyCed, Jan 28, 2005, in forum: Java
    Replies:
    1
    Views:
    736
    Dag Sunde
    Jan 28, 2005
  4. Fran Cottone
    Replies:
    1
    Views:
    3,659
    Esmond Pitt
    Mar 22, 2005
  5. Jan Schulze
    Replies:
    1
    Views:
    569
    Esmond Pitt
    Mar 26, 2005
Loading...

Share This Page