Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8987155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:43:19+00:00 2026-06-15T21:43:19+00:00

So I have a program (which is a simple chat client), and I’m trying

  • 0

So I have a program (which is a simple chat client), and I’m trying to send, from the server, an updated client. To do this, I’m making use of the serializable keyword. The existing client can load and execute code from this kind of object transmission, so that’s all good. My issue is that the program features a few inner classes. Now, the way I’m doing this is to create an array consisting of all the class files necessary for the update, then iterating through it and sending them off one at a time. My problem is that the order in which they are sent has an effect on execution. If I send the inner classes first, the code works, and the client updates, but throws “ClassDefNotFound” exceptions any time one of the inner classes is used. Alternatively, if I send the inner classes last, the code does not work at all, and the client does not update.

private static final Class[] clientUpdates = 
{EntryPanel.EnterSendListener.class, EntryPanel.ButtonSendListener.class,   
EntryPanel.class, MessagePanel.class, GUIClient.ClientThread.class, GUIClient.class,  
UpdateClientMessage.class};

Is my array, where anything with a path in is an inner class. The last element is one that runs a method starting the new client when it is sent.

for(Class c : clientUpdates)
            {
                String name = c.getName();
                InputStream is = c.getClassLoader().getResourceAsStream(
                        name.replaceAll("\\.", "/") + ".class");

                ByteArrayOutputStream os = new ByteArrayOutputStream();
                byte[] buff = new byte[1024];
                int i = is.read(buff);

                while(i != -1)
                    {
                        os.write(buff, 0, i);
                        i = is.read(buff);
                    }

                byte[] bs = os.toByteArray();

                NewMessageType m = new NewMessageType(name, bs);
                queue.put(m);
            }
            queue.put(new UpdateClientMessage("localhost", port));

Is the code I’m using to send the class definitions. NewMessageType is a class designed to contain raw byte data of a class and transmit it across, to be read on the other side. Putting things on the Queue simply transmits them across.

I’ll be the first to admit that I’m not wonderful at networking stuff, and serialisability is not my strong suit. However, I could really do with some help here. It would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:43:20+00:00Added an answer on June 15, 2026 at 9:43 pm

    I fixed this, by the way. The issue was not to do with inner classes, but circular dependencies (i.e. two classes both requiring the definition of the other). In order to remove these, I added some abstract classes that one class in the dependency referred to, and the other inherited. In this way, as long as I sent the abstract ones first, there would be no issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple chat program using WCF service. One service use for server and
I have been trying to create a simple program with Python which uses OpenCV
I have to write a simple chat in C. One program is a server
I have a simple program which creates a thread, and waits when this thread
I have a fairly simple program which grabs values from a file on the
Making a simple program which will generate a multiple choice form. I have an
Hello I am making a simple program which is taking input from user and
Simple synopsis: I have a program which needs authentication from user to get access
I have a chat program implemented in Java. The client can send lots of
I have a simple program which is able to change the background color after

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.