rmi java.lang.ClassNotFoundException: testrmi2.fileserverimpl_Stub

Hola chicos, estoy programando una aplicación rmi simple, pero tengo un problema. Si ejecuto el registro en el mismo directorio, funciona; pero si cambio el directorio desde el que ejecuto el registro no lo hago. Creo que es imposible esta situación. El registro funcionaría genéricamente desde otro host, pero solo el cambio de directorio detendrá su funcionalidad. Estoy trabajando en este problema por 3 días sin solución, también cambio todas las configuraciones posibles del parámetro de base de código pero nada. Describo la situación y el código con el directorio:

fileserver.java:

`package testrmi2;
import java.rmi.*;

public interface fileserver extends Remote  {
 public void scrivifile(String nomefile, String arg) throws  RemoteException;
}

`fileserverimpl.java:

    package testrmi2;

import java.io.*;
import java.rmi.*;
import java.rmi.server.*;

public class fileserverimpl extends UnicastRemoteObject implements fileserver{
  public fileserverimpl() throws RemoteException {
    super();
  }
  public void scrivifile(String nomefile, String arg) throws RemoteException {
    try {
      FileWriter myfile = new FileWriter(nomefile);
      myfile.write(arg);
      myfile.close(); }
    catch (Exception e) {System.out.println(e);}
  }
  public static void main (String arg[]) {
    try {
       fileserverimpl s = new fileserverimpl();
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new RMISecurityManager());
        }
        String codebase = System.getProperty("classpath");
        System.out.println("Trying to access code base: " + codebase+"\n\nuse is "+System.getProperty("useCodebaseOnly"));
       Naming.rebind("//127.0.0.1:2005/fileserverimpl", s);
       System.out.println("Server attivato.");
} catch (Exception e) {System.out.println("errore inizializzazione server\n\n"+e.getMessage()+"\n\n\n");

}}}

cliente.java:

    package testrmi2;

import java.rmi.*;
import java.io.*;

public class client {
  public static void main (String arg[]) {
    fileserver myserver;
    String nomefile=" ";
    String testo=" ";
    System.out.println("Scrivi il nome del file");
    nomefile=ReadString();
    System.out.println("Scrivi il testo");
    testo=ReadString();
    try {
       myserver = (fileserver)   Naming.lookup("//127.0.0.1:2005/fileserverimpl");
        myserver.scrivifile(nomefile, testo);
      } catch (Exception e) {System.out.println(e);}
    }

   public static String ReadString() {
      BufferedReader stdIn =new BufferedReader(new InputStreamReader(System.in));
      String s=" ";
     try{
       s=stdIn.readLine();
      }
       catch(IOException e) {System.out.println(e.getMessage()); }
    return s;
   }
}

y el archivo de política es:

grant {
        // Allow everything for now
        permission java.security.AllPermission;
}; 

Todos estos archivos están en el directorio:

/ Usuarios / franco / Desktop / prova

para compilarlo voy al directorio / Users / franco / Desktop / prova y lo hago en la terminal:

javac -cp . -d . *.java
rmic rmic testrmi2.fileserverimpl
jar cvf testrmi2.jar testrmi2/fileserver.class testrmi2/fileserverimpl_Stub.class

después de ejecutar el registro en otro terminal con los siguientes comandos pero en otro directorio:

export classpath=""
rmiregistry 2005 &

Finalmente, ejecutaría el archivo filesereveimpl.class con el terminal en el directorio / Users / franco / Desktop / prova y escribo:

java -classpath /Users/franco/Desktop/prova/ -Djava.rmi.server.codebase=file:/Users/franco/Desktop/prova/testrmi2.jar  -Djava.security.policy=testrmi2/policy testrmi2.fileserverimpl &

pero los resultados son:

    Trying to access code base: null

use is null
errore inizializzazione server

RemoteException occurred in server thread; nested exception is: 
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
    java.lang.ClassNotFoundException: testrmi2.fileserverimpl_Stub

También intento publicar el jar en un servidor web local xampp e intentar ejecutarlo con lo siguiente:

java -classpath .  -Djava.rmi.server.codebase=http://127.0.0.1/testrmi2/  -Djava.security.policy=testrmi2/policy  testrmi2.fileserverimpl &

o con :

java -classpath .  -Djava.rmi.server.codebase=http://127.0.0.1/testrmi2.jar  -Djava.security.policy=testrmi2/policy  testrmi2.fileserverimpl &

Pero tengo los mismos resultados.

¡¡¡Por favor, ayúdame!!! Me estoy volviendo loca!

Respuestas a la pregunta(2)

Su respuesta a la pregunta