I have set up a basic server application. It contains three files namely
Arith.java (implements the Remote interface)
ArithImpl.java (implements Arith.java the server) and
ArithApp.java which is the client Application
All of these are in the same package. I have compiled all of these files and I execute the rmic ArithImpl command from within the ArithImpl.java file via Runtime.getRuntime.exec(...);
The stub and skeleton files are generated and still I get a class not found exception. I have checked the class path and these files are within the class path.
If anyone could help me I'd greatly appreciate it. Thanks
public class ArithImpl extends UnicastRemoteObject implements Arith{
public static final
String HOST_NAME = "localhost";
public static final String ROOT = "C:/Work/Thesis~1/LearningRMI/";
public static final String CLASSPATH = ROOT;
public static final String POLICY_FILE = CLASSPATH+"policies/rmi.policy";
public static final String RMI_LOCATION = "C:/Progra~1/java/jdk1.5.0_03/bin/";
String objectName;
public ArithImpl(String s) throws RemoteException{
super();
objectName = s;
}
public int[] add(int[] a, int[] b) throws RemoteException {
int c[] = new int[10];
for (int i=0; i<10; i++)
c = a+b;
return c;
}
public static void main(String[] args) {
System.setProperty("java.security.policy",POLICY_FILE);
System.setProperty("java.class.path",CLASSPATH);
String rmic = RMI_LOCATION+"rmic -vcompat -classpath "+CLASSPATH+" "+ArithImpl.class.getName();
String registry = RMI_LOCATION+"\\rmiregistry";
try{
Runtime rt = Runtime.getRuntime();
rt.exec(rmic);
rt.exec(registry);
}
catch (IOException e){
e.printStackTrace();
}
RMISecurityManager sm = new RMISecurityManager();
System.setSecurityManager(sm);
try{
Naming.rebind("//"+HOST_NAME+"/ArithServer", obj);
System.out.println("ArithServer bound in registry");
}
catch (Exception e){
e.printStackTrace();
}
}