Em đang test 1 ứng dụng Java RMI
code thế này
Code:
import java.rmi.*;
public interface Calculator extends Remote
{
public int addNum(int x,int y) throws RemoteException;
}
Code:
import java.rmi.*;
public class CalculatorImpl implements Calculator
{
public int addNum(int x,int y) throws RemoteException
{
System.out.println("Client request to calculate");
return (x+y);
}
}
Code:
import java.rmi.*;
import java.rmi.server.*;
public class CalculatorServer
{
public static void main (String args[])
{
try
{
CalculatorImpl c = new CalculatorImpl();
System.out.println("Exporting Calculator...");
UnicastRemoteObject.exportObject(c);
Naming.bind("rmi://localhost/MyCalculator",c);
System.out.println("Register Calculator!");
}
catch (Exception e)
{
System.out.println(e);
}
}
}
Em dùng Eclipse (đã add Plug-in RMI). Run thì nó chạy ra lỗi này
Code:
Exporting Calculator...
java.rmi.StubNotFoundException: Stub class not found: CalculatorImpl_Stub; nested exception is:
java.lang.ClassNotFoundException: CalculatorImpl_Stub
Em đã search, do chưa set CLASSPATH. Nhưng sau khi set CLASSPATH. Vẫn ko được.
Code:
echo $JAVA_HOME
/usr/lib/jvm/java-6-sun
echo $CLASSPATH
/usr/lib/jvm/java-6-sun
Em dùng Distro Ubuntu 9.04 - Eclipse GANYMEDE SDK 3.4.2