How to serialize ArrayList of Objects?

When I write in the ObjectOutputStream my ArrayList ( out.writeObject(myarray) , I have the message : java.io.NotSerializableException.How can I serialize this arraylist? Thanks
[198 byte] By [berlinerwurma] at [2007-11-27 1:26:29]
# 1
I am working with sockets.
berlinerwurma at 2007-7-12 0:21:07 > top of Java-index,Core,Core APIs...
# 2
Are the objects in the ArrayList also serializable?An ArrayList is serializable if-and-only-if every object in it are also Serializable.
KathyMcDonnella at 2007-7-12 0:21:07 > top of Java-index,Core,Core APIs...
# 3
They are Players..if they are not serializable..how can I work between server-client with these objects?
berlinerwurma at 2007-7-12 0:21:07 > top of Java-index,Core,Core APIs...
# 4

Did you write the "Player" class?

If so, you need to make it Serializable.

Do you know what that means?

public class Player { } // This class is not serializable

public class Player implements Serializable { } // This class is serializable

(Of course, if Player is Serializable, then the next thing you have to do

is to make sure every nontransient field in Player is also serializable...)

KathyMcDonnella at 2007-7-12 0:21:07 > top of Java-index,Core,Core APIs...
# 5

> They are Players..if they are not serializable..how

> can I work between server-client with these objects?

make them serializable! all serializable means really is "can be broken down into data that can be described in terms of primitives", more or less. all that needs to be true is that all the instance variables of your class are either serializable themselves, or marked as transient. if you post the Player class, we can see what is and isn't serializable about it

don't fall into the trap of thinking that anything implementing Serializable is actually serializable. implementing that "interface" is only a promise to other classes, a promise it's easy to break

georgemca at 2007-7-12 0:21:07 > top of Java-index,Core,Core APIs...
# 6
Player is an imported class : javax.media.PlayerHow can I make it serializable..?Lots of thanks KathyMcDonnell...I'm a beginner with "serialize".
berlinerwurma at 2007-7-12 0:21:07 > top of Java-index,Core,Core APIs...
# 7

javax.media.Player is just a controller that allows users to play/stop/rewind.

You mentioned you want to send this to another computer (between server-and-client you said).

That won't work.

Even if you could transport this controller object to another computer,

that other computer won't be able to use it to control the media file.

Serialization is not the answer. What are you really trying to do?

KathyMcDonnella at 2007-7-12 0:21:07 > top of Java-index,Core,Core APIs...
# 8
I think I'm going in the bad way...I want to work with objects between differents computers..I think I have to ask to another forum..Lots of thanks.
berlinerwurma at 2007-7-12 0:21:07 > top of Java-index,Core,Core APIs...
# 9
Try RMI. You can export the functionality of your Player via RMI callsso that other computers can invoke it on your primary computer.
KathyMcDonnella at 2007-7-12 0:21:07 > top of Java-index,Core,Core APIs...