This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI - NoClassFoundException" Watch "RMI - NoClassFoundException" New topic
Author

RMI - NoClassFoundException

mj deacon
Greenhorn

Joined: Dec 09, 2005
Posts: 2
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();
}
}
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 ]
Ilias
Greenhorn

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: http://aspose.com/file-tools
 
subject: RMI - NoClassFoundException
 
Similar Threads
Java RMI Client AccessControlException
Problem while starting rmi server
java.security AccessControlException : access denied?
Access Control Exception
java.rmi. NotBoundException: Student1001?