Loading a savable .j3o file dosnt work

Hey folks,
im trying to load a j3o file that was exported with the savable interface -> (https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:save_and_load):

File file = new File(fileString); // file gets loaded correctly
TestSwing test = (TestSwing) importer.load(file); // importer now has all Information from the j3o probably correctly (looked in the SDK watch) BUT RETURNS NULL
test.read(importer); // as test is still null this line can’t really work
The importer should return a savable object but returns nothing. Why is that? (the file should be correct)

Why do you use the savable interface but not the jme loader system? Anyway using File is almost always a bad idea as in a deployed app you have a classpath and not files anymore.
The content of this post is meant to be read as a straight information or question without an implicit dismissive stance or interest in having the other party feel offended unless there’s emotes that hint otherwise or there’s an increased use of exclamation marks and all-capital words.

Thanks for the fast reply,
Im using files because my Programm is an Editor and has to be able to load user created content (not content created by me)
(im gessing by jme loader system you mean the possability to load stuff in the sdk itsself which dosnt help allot. If you mean something different pls correct me)
Why does the load funktion not return anything when it should return a Instance from Savable? (file should be correct)
and if the file is not correct, what is a likely mistake that causes the file to be incorrect (using a instance from BinaryExporter)
allthought there is no error exporting and the file gets created
Help is really appreciated

hey folks
I just want to save and load Custom classes …
basecly like here-> https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:save_and_load
On the bottom in the “Custom Savable Class” Sektion is explained how to make a class savable. I did that.
How do i save it now? use a BinaryImporter? or loadModel because it is saved kind of as a spatial?
Pls Help me i havn’t got a clue why its not working…

Just found out about a serious Issue… The importer only works when you load in a object that has a not in code declared Constructor … (dosn’t make sens to me).
how can i get this info to the right people?

Thats normal, it has to instantiate the empty object somehow. So just add the empty constructor.
The content of this post is meant to be read as a straight information or question without an implicit dismissive stance or interest in having the other party feel offended unless there’s emotes that hint otherwise or there’s an increased use of exclamation marks and all-capital words.

No, correct you there adding a empty constructor dosnt work it only works if there is the standart empty constructor there because i havnt declared any at all…
so i would have to destroy all constructors i wrote and set the values that would be set in the constructor at a later time…

@emtonsit said: so i would have to destroy all constructors i wrote and set the values that would be set in the constructor at a later time...
Thats the whole point of the read() method.. So yes, you just have to add an empty constructor and then properly reconstruct the object in the read() method, as intended. The content of this post is meant to be read as a straight information or question without an implicit dismissive stance or interest in having the other party feel offended unless there's emotes that hint otherwise or there's an increased use of exclamation marks and all-capital words.

im doing exactly that…
i

@normen said: add an empty constructor and then properly reconstruct the object in the read() method
and i have the error described above

Then you do it wrong. Also that code still does it wrong. To load a file from anywhere on the disk add the filesystem root to the assetmanager, then you can load any file with it.