So, I wrote these class:
public class FicherosDeCiudadanos {
public static int numCiudadanos (File f) {
try{
Scanner texto=new Scanner(f);
int contador=0;
while(texto.hasNextLine()){
contador++;
texto.nextLine();
}
texto.close();
return contador;
}
}
public static Ciudadano[] leerFichero (File f) {
try{
Scanner texto=new Scanner(f);
//This next line throws classNotFound when debbugging but only
//when evaluating Ciudadano[]
Ciudadano[] tablaCiudadano = new Ciudadano[numCiudadanos(f)];
....
//TO-DO
}
}
I verified it worked, and it did, the method leerFichero() did the job perfectly. It created an object array of Ciudadano with the code in TO-DO. But then, in another package, I call the method leerFichero() and it gets there, works out numCiudadanos() to set the lenght of the array, but then when it gets to Ciudadano[] it throws ClassNotFoundException, and the program stops. It still works when I use it from its own package.
I'm guessing this is the stack
Thread [main] (Suspended)
owns: Object (id=36)
owns: Object (id=37)
ClassNotFoundException(Throwable).<init>(String, Throwable) line: 286
ClassNotFoundException(Exception).<init>(String, Throwable) line: not available
ClassNotFoundException(ReflectiveOperationException).<init>(String, Throwable) line: not available
ClassNotFoundException.<init>(String) line: not available
URLClassLoader$1.run() line: not available
URLClassLoader$1.run() line: not available
AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]
Launcher$ExtClassLoader(URLClassLoader).findClass(String) line: not available
Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available
Launcher$AppClassLoader.loadClass(String, boolean) line: not available
Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available
FicherosDeCiudadanos.leerFichero(File) line: 54
Operaciones.nombreCliente(int) line: 80
Operaciones.listadoCompras() line: 37
TrabajoProg1.ejecutarOperacion(int) line: 40
TrabajoProg1.main(String[]) line: 22