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

  • SEARCH
  • Home
  • 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 8309933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:16:41+00:00 2026-06-08T19:16:41+00:00

In both client and server classes, I have an exact same inner class called

  • 0

In both client and server classes, I have an exact same inner class called Data. This Data object is being sent from the server using:

ObjectOutputStream output= new ObjectOutputStream(socket.getOutputStream());
output.writeObject(d);

(where d is a Data object)

This object is received on the client side and cast to a Data object:

ObjectInputStream input = new ObjectInputStream(socket.getInputStream());
Object receiveObject = input.readObject();
if (receiveObject instanceof Data){
    Data receiveData = (Data) receiveObject;
    // some code here... 
}

I’m getting a java.lang.ClassNotFoundException: TCPServer$Data on this line Object receiveObject = input.readObject();

My guess is that it’s trying to to look for the Data class in the Server side and can’t find it, but I’m not sure… How do I fix this?

  • 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-08T19:16:42+00:00Added an answer on June 8, 2026 at 7:16 pm

    What you were trying to do is something along the lines of the following:

    class TCPServer {
        /* some code */
    
        class Data {
    
        }
    }
    
    class TCPClient {
        /* some code */
    
        class Data {
    
        }
    }
    

    Then you are serializing a TCPServer$Data and trying to unserialize it as a TCPClient$Data. Instead you are going to want to be doing this:

    class TCPServer {
        /* some code */
    
    }
    
    class TCPClient {
        /* some code */
    
    }
    
    class Data {
        /* some code */
    
    }
    

    Then make sure the Data class is available to both the client and the server programs.

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

Sidebar

Related Questions

Client + Server are both written in Javascript. I don't have a master game
I have three classes: Client Session Socket Both Session & Socket depeand on the
I have a client-server application, which intercommunicate via WCF. They also both use Castle
I implemented a client and server programms using RMI. I wrote this both server
I have a server-client application in which I can modify both codebases. The client
Currently I'm using Mustache templates ( http://mustache.github.com/ ) both on the client and server-side,
I've developed a small (very small) ftp client and server. Both of these programs
I'm developing an application that uses webservices in python, both sides (server and client)
Our client wants to support both SQL Server and Oracle in the next project.
I'm talking about both server-side and client-side. I know a little bit about Go,

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.