   [java] RMI
  I'm trying to write an hello world rmi application, but I keep getting an errorjava.lang.ClassNotFoundException: javainterfaceWhy do i get this error? and how do I solve it?I have 3 classes:main.javaimport java.*;import java.math.BigInteger;import java.rmi.*;public class main {  public static void main (String[] argv)   {  // Create and install a security manager if(System.getSecurityManager() == null) {  System.setSecurityManager(new RMISecurityManager()); }  try { Naming.rebind ("rmi://127.0.0.1:1099/", new hello ("Hello, world!")); System.out.println ("Hello Server is ready.");    } catch (Exception e) { System.out.println ("Hello Server failed: " + e);    }  }}javainterface.javaimport java.rmi.Remote;import java.rmi.RemoteException;public interface javainterface extends Remote {public String say() throws RemoteException;}and hello.javaimport java.rmi.*;import java.rmi.server.*;public class hello extends UnicastRemoteObject implements javainterface {  private String message;  public hello (String msg) throws RemoteException {    message = msg;  }  public String say() throws RemoteException {    return message;  }}I have rmiregistry running and Im using eclipse ide.[Edited by - frankfrank on May 28, 2009 6:00:09 AM]
  javaiterface doesn't seem to be in the class path.Is javainterface compiled? Where is the .class file located?Other note: You should definitely work on your naming. There are several conventions that make your life easier:- place your classes in packages- class names are captialized camel case, e.g. Main (so you don't mix it up with the main method);  Right now the .class files are in the project direcotryC:\Documents and Settings\Win\workspace2\rmiserverHow can I set the classpath in eclipse? isnt it done automatically?;  i got it working. both client and server have to be in the same package.I can start it now within netbeans or eclipse, but how can I start it from a console?I tried: java clientbut I get the following:Exception in thread "main" java.lang.NoClassDefFoundError: clientCaused by: java.lang.ClassNotFoundException: client   at java.net.URLClassLoader$1.run(Unknown Source)   at java.security.AccessController.doPrivileged(Native Method)   at java.net.URLClassLoader.findClass(Unknown Source)   at java.lang.ClassLoader.loadClass(Unknown Source)   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)   at java.lang.ClassLoader.loadClass(Unknown Source)   at java.lang.ClassLoader.loadClassInternal(Unknown Source)Could not find the main class: client.  Program will exit.;  You need to set the java.rmi.server.codebase property for this to run standalone.The RMI Registry uses the codebase to locate the class files of any objects that will be available remotely (so that clients can download the classes). If the client is going to pass objects as parameters to your server, you may need to set the codebase for your client too--but in your example, that won't be needed.See the following (might need to search for 'codebase'): http://java.sun.com/j2se/1.5.0/docs/guide/rmi/codebase.htmlhttp://java.sun.com/docs/books/tutorial/rmi/running.htmlhttp://java.sun.com/j2se/1.4.2/docs/guide/rmi/javarmiproperties.htmlYou can set the codebase in code or via the command line, like so:java -Djava.rmi.server.codebase="file:/%CD%/server.jar" -jar server.jarThat's for Windows. Replace %CD% with the directory 'server.jar' is sitting in. And replace 'server.jar' with whatever you compile your server as.   