We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
serialization (Read 1011 times)
serialization
Apr 29th, 2008, 8:29am
 
I have written a fairly long piece of code for a new artwork. Most of it was originally written and tested in Java. I am trying to port it to Processing, so as to take advantage of the video library. The problem is that I keep on being hit with a:
java.io.NotSerializableException: java.lang.Object

This never happened in Java. I wonder why this happens specifically in Processing, and not in Java.

I have created a Node class that implements serializable, and I am trying to save an array of Node objects into a file. Is there a problem about implementing the serializable interface? Anything I should check or add?

Thanks to anyone who might help.
Re: serialization
Reply #1 - Apr 29th, 2008, 5:29pm
 
Unfortunately since everything within processing is ultimately wrapped into a PApplet object, you can't serialize your classes, as it's the whole PApplet that ends up getting serialised as far as I can tell.
Re: serialization
Reply #2 - Apr 30th, 2008, 4:09am
 
Thanks for your prompt reply.

Do you know whether there a way of saving an array of objects into a file and then reading those objects?

Re: serialization
Reply #3 - May 1st, 2008, 11:02am
 
I have solved my problem by first saving the data that I need as primitive datatypes and then reconstructing the objects from the data when I open the file. But there might be cases where the convenience of being able to save (for instance) an array of objects might come in handy.
Re: serialization
Reply #4 - Jul 18th, 2008, 7:06pm
 
Hi,

to solve this problem I avoid to use inner classes.
If you don't fell like to create a new package there's a quick and dirty solution by creating a tab for each class and save it with .java extension.

Alessandro
Page Index Toggle Pages: 1