I have a textual-game that saves the state of an object using the serializable class, the object is stored in this way:
FileOutputStream fileOut = new
FileOutputStream("./lib/savedGame/savedGame.ser");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(obj);
out.close();
fileOut.close();
System.out.printf("Serialized data is saved in ./lib/savedGame/savedGame.ser");
} catch (IOException i) {
i.printStackTrace();
}
}
the problem is that I tried to create the jar file and then put it into a folder then create the folder ./lib/savedGame/ inside and in MacOsx works fine, when i try to execute the jar on windows it does not save anything. The same thing happens if i try to place a serialized object in a folder and deserialize it. works for macOs but not for windows. I think windows maybe executes the file from a different folder so it does not find the serializable object?