Can´t load images from server to client

Discussion in 'Java' started by Knute Johnson, Jul 30, 2005.

  1. Re: =?ISO-8859-1?Q?Can=B4t_load_images_from_server_to_?==?ISO-8859-1?Q?client?=

    Pontus wrote:
    > I try to load images with socketconnection from a server to a client written
    > in java. I get "java.io.NotSerializableException: sun.awt.windows.WImage"
    > when I try with objectstreams. The server implements the Serializable
    > interface.
    >
    > If I remove everything about images in both the client and the server, the
    > transfer works with string-objects.
    >
    > How do I transfer images from a server to a client with sockets?
    >
    > Thanks in advance!
    >
    > Pontus
    >
    >


    Neither Image or BufferedImage are Serializable so they can't be
    read/written to/from an ObjectInput/OutputStream. You will need to put
    the image into some type that is Serializable. An int[] will do.

    knute...

    email s/nospam/knute/
    Knute Johnson, Jul 30, 2005
    #1
    1. Advertising

  2. Knute Johnson

    Pontus Guest

    I try to load images with socketconnection from a server to a client written
    in java. I get "java.io.NotSerializableException: sun.awt.windows.WImage"
    when I try with objectstreams. The server implements the Serializable
    interface.

    If I remove everything about images in both the client and the server, the
    transfer works with string-objects.

    How do I transfer images from a server to a client with sockets?

    Thanks in advance!

    Pontus
    Pontus, Jul 30, 2005
    #2
    1. Advertising

  3. Knute Johnson

    jan V Guest

    > Neither Image or BufferedImage are Serializable so they can't be
    > read/written to/from an ObjectInput/OutputStream. You will need to put
    > the image into some type that is Serializable. An int[] will do.


    Interesting to see that Swing's ImageIcon is Serializable.. it must make the
    effort to overcome the Image/BufferedImage non-Serializable obstacle.
    jan V, Jul 31, 2005
    #3
  4. Re: =?ISO-8859-1?Q?Can=B4t_load_images_from_server_to_?==?ISO-8859-1?Q?client?=

    jan V wrote:
    >>Neither Image or BufferedImage are Serializable so they can't be
    >>read/written to/from an ObjectInput/OutputStream. You will need to put
    >>the image into some type that is Serializable. An int[] will do.

    >
    >
    > Interesting to see that Swing's ImageIcon is Serializable.. it must make the
    > effort to overcome the Image/BufferedImage non-Serializable obstacle.
    >
    >


    Note the warning for ImageIcon:

    Warning: Serialized objects of this class will not be compatible with
    future Swing releases. The current serialization support is appropriate
    for short term storage or RMI between applications running the same
    version of Swing. As of 1.4, support for long term storage of all
    JavaBeansTM has been added to the java.beans package. Please see
    XMLEncoder.

    --

    Knute Johnson
    email s/nospam/knute/
    Knute Johnson, Aug 1, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John
    Replies:
    1
    Views:
    683
    Andrew S.
    Apr 9, 2004
  2. -
    Replies:
    2
    Views:
    396
    Alan Krueger
    Jul 29, 2005
  3. wensa
    Replies:
    0
    Views:
    308
    wensa
    Feb 22, 2008
  4. John
    Replies:
    1
    Views:
    136
    Andrew S.
    Apr 9, 2004
  5. Replies:
    0
    Views:
    179
Loading...

Share This Page