tags:

views:

28

answers:

1

Hi again, I'm trying to run jGuru examples of RMI from the tutorial at (http://java.sun.com/developer/onlineTraining/rmi/RMI.html) but they didn't compile in the command line, so I can't run rmic and advance the tutorial:

$javac Calculator.java

$javac CalculatorImpl.java
CalculatorImpl.java:6: cannot find symbol
symbol: class Calculator
    implements Calculator {
               ^
1 error

both classes are exactly like they're in the jguru tutorial: Interface:

public interface Calculator
        extends java.rmi.Remote {

    public long add(long a, long b)
            throws java.rmi.RemoteException;

    public long sub(long a, long b)
            throws java.rmi.RemoteException;

    public long mul(long a, long b)
            throws java.rmi.RemoteException;

    public long div(long a, long b)
            throws java.rmi.RemoteException;
}

Class:

public class CalculatorImpl
    extends
      java.rmi.server.UnicastRemoteObject
    implements Calculator {

    // Implementations must have an
    //explicit constructor
    // in order to declare the
    //RemoteException exception
    public CalculatorImpl()
        throws java.rmi.RemoteException {
        super();
    }

    public long add(long a, long b)
        throws java.rmi.RemoteException {
        return a + b;
    }

    public long sub(long a, long b)
        throws java.rmi.RemoteException {
        return a - b;
    }

    public long mul(long a, long b)
        throws java.rmi.RemoteException {
        return a * b;
    }

    public long div(long a, long b)
        throws java.rmi.RemoteException {
        return a / b;
    }
}

Environment vars: (@Windows XP)

JAVA_HOME=C:\Program Files\Java\jdk1.6.0_20
CLASSPATH=C:\Program Files\Java\jdk1.6.0_20
Path=C:\Program Files\Java\jdk1.6.0_20\;...
A: 

You certainly forgot to import your interface. You should check that.


For example, this is the compilation error given if the Lol class isn't imported :

Test.java:3: cannot find symbol  
symbol  : class Lol  
location: class Test  
         static Lol l;  
                ^
Colin Hebert
well I thought that it was not needed since they're in the same directory (and belongs to the same package <default package>)
AndreDurao
So I've imported "import Calculator;" and gives me 2 errors: CalculatorImpl.java:1: '.' expectedimport Calculator; ^CalculatorImpl.java:1: ';' expectedimport Calculator; ^2 errors
AndreDurao
Hum, I thought you removed the `package` statement. Your code runs fine on my computer, without `package` (and `import`). But the two java files need to be in the same folder.
Colin Hebert
and they are on the same folder. I guess thats something wrong w/ this jdk, I'll try to test it in other pc. Thanks for your help Colin.
AndreDurao
It is practically certain that the problem is in your code or directory layout, not the JDK.
EJP