File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Distributed Java and the fly likes RMI - NoClassFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI - NoClassFoundException" Watch "RMI - NoClassFoundException" New topic

RMI - NoClassFoundException

mj deacon

Joined: Dec 09, 2005
Posts: 2
I have set up a basic server application. It contains three files namely (implements the Remote interface) (implements the server) and 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 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{
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) {

String rmic = RMI_LOCATION+"rmic -vcompat -classpath "+CLASSPATH+" "+ArithImpl.class.getName();
String registry = RMI_LOCATION+"\\rmiregistry";

Runtime rt = Runtime.getRuntime();
catch (IOException e){

RMISecurityManager sm = new RMISecurityManager();
Naming.rebind("//"+HOST_NAME+"/ArithServer", obj);
System.out.println("ArithServer bound in registry");
catch (Exception e){
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
You can set the classpath, where your java files reside, as your environment variable.

I have experienced that on windows this error persist even after setting the environment variable. So, copy those java files in your JAVA_HOME/bin/, where your rmic resides. It would surely work. After that try to rmic at the original position.
[ December 11, 2005: Message edited by: Adeel Ansari ]

Joined: Dec 03, 2005
Posts: 2
How are you executing rmiregistry?? check which rmiregistry ur running on the title bar, because rmiregistry also exists in oracle. Always run rmiregistry from your current console e.g. c:\rmi> start rmiregistry
otherwise it gives class not found exception or nested exception in case of oracle registry
I agree. Here's the link:
subject: RMI - NoClassFoundException
jQuery in Action, 3rd edition