jGuru RMI示例不编译

时间:2010-09-09 17:51:01

标签: java rmi

我正在尝试从(http://java.sun.com/developer/onlineTraining/rmi/RMI.html)教程中运行jGuru的RMI示例,但是它们没有在命令行中编译,所以我无法运行rmic并推进教程:

$javac Calculator.java

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

这两个类就像他们在jguru教程中一样: 的接口:

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;
}

类别:

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;
    }
}

环境变量: (@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\;...

1 个答案:

答案 0 :(得分:0)

你当然忘了导入你的界面了。你应该检查一下。


例如,如果未导入Lol类,则会出现编译错误:

Test.java:3: cannot find symbol  
symbol  : class Lol  
location: class Test  
         static Lol l;  
                ^