I saw various posts on this topic but they didnt help me. I deleted my Netbeans cache and Compile on Save was not checked. I just try to load a .dat File and use the data that was serialized in there. It works perfectly in JavaEditor but I get the error java.lang.ClassNotFoundException: Example
in Netbeans.
The code I used to load the .dat :
public static void load(){
ArrayList<Example> ex = new ArrayList<Example>();
FileInputStream fis;
ObjectInputStream ois;
try{
fis = new FileInputStream("ExampleList.dat");
ois = new ObjectInputStream (fis);
while (fis.available()>0){
Example exam = (Example)ois.readObject();
ex.add(exam);
}
ois.close();
fis.close();
} catch (Exception e){
System.out.println(e);
}
The Example.jar:
package ExampleTest;
import java.io.*;
public class Example implements Serializable{
private String name;
public Example(){
}
//Getter and Setter
}
Doing something in the main method like Example ex = new Example();
works perfectly fine so netbeans should have found the class..