title: Runtime Exception while instantiating Server class for rmiregistry
body: <p>I tried the same program on my Ubuntu VM and the program even yielded the correct output but on Windows its giving a weird runtime exception:</p>
  
  <pre>
  e:\java\rmi final>javac *.java
  e:\java\rmi final>rmic ServerImplement
  e:\java\rmi final>rmiregistry 20361  
  &lt;&lt; BLANK , fine >>
  e:\java\rmi final>java ServerMain 20361  
  java.rmi.ServerException: RemoteException occurred in server thread;   
  nested exception is:     
       java.rmi.UnmarshalException: error unmarshalling arguments;   
  nested exception is:  
  
          java.lang.ClassNotFoundException: ServerImplement_Stub
          at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396)
          at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
          at sun.rmi.transport.Transport$1.run(Transport.java:159)
          at java.security.AccessController.doPrivileged(Native Method)
          at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
          at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)  
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)  
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)  
  
          at java.lang.Thread.run(Thread.java:619)  
          at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)  
          at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
          at sun.rmi.server.UnicastRef.invoke(Unknown Source)
          at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
          at java.rmi.Naming.rebind(Unknown Source)
          at ServerMain.main(ServerMain.java:9)  
  Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
  
          java.lang.ClassNotFoundException: ServerImplement_Stub
          at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
          at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386)
          at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
          at sun.rmi.transport.Transport$1.run(Transport.java:159)
          at java.security.AccessController.doPrivileged(Native Method)
          at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
          at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
          at java.lang.Thread.run(Thread.java:619)
  
  Caused by: java.lang.ClassNotFoundException: ServerImplement_Stub
  
          at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
          at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Class.java:247)
          at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:434)
          at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
          at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
          at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
          at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
          at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
          at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
          at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
          at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
          at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
          ... 12 more
  </pre>
  
  <p>Here is my <code>ServerMain</code> class:</p>
  
  <pre><code>import java.io.*;
  import java.rmi.*;
  
  class ServerMain
  {
   public static void main(String[] args)
   {
     try {
          Naming.rebind("//localhost:"+args[0]+"/TestClass",new ServerImplement());
          System.out.println("TestClass is uploaded on the server. on port "+args[0]);
  
      }  
     catch(Exception e)
     {
         //System.out.println("FAILED. ERROR: ");
          e.printStackTrace();
     } 
   }
  }
  </code></pre>
  
  <p>On Ubuntu:</p>
  
  <pre>
  machine@ubuntu:~/rmi final$java ServerMain 20361
  TestClass is uploaded on the server. on port 20361
  </pre>