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 9161435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:57:59+00:00 2026-06-17T13:57:59+00:00

server thread package schatserver; public ServerThread(Socket socket) { this.socket = socket; this.start(); } public

  • 0

server thread

package schatserver;

public ServerThread(Socket socket) {
        this.socket = socket;
        this.start();
    } 



 public void run() {
        try {
             ObjectInputStream inputStream = new ObjectInputStream(this.socket.getInputStream());
              ObjectOutputStream outputStream = new ObjectOutputStream(this.socket.getOutputStream());
        container = (Message) inputStream.readObject();  
        .....
        ..... etc

and “Message class” contains at both server side and client side

public class Message implements Serializable {

private String login;
private String message;
private String[] users;
private Date time;

public Message(String login, String message){ //for client
        this.login = login;
        this.message = message;
        this.time = java.util.Calendar.getInstance().getTime();
    }


 public Message(String login, String message, String[] users){//for server
        this.login = login;
        this.message = message;
        this.time = java.util.Calendar.getInstance().getTime();
        this.users = users;
    }

trying sending Object “Message”

private static Message message;

public void Connect() {
        try {            
            sock = new Socket(ClientConfig.HOST, ClientConfig.PORT);
            System.out.println("Connected with: " + ClientConfig.HOST);                        
            ObjectOutputStream out = new ObjectOutputStream(sock.getOutputStream());
            out.writeObject(message);
            out.flush();

getting “java.lang.ClassNotFoundException: socketchatclient.Message” at this line

 container = (Message) inputStream.readObject();  

can someone explain me how should i send Object Message?

socketchatclient. – it’s client package

  • 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-17T13:58:00+00:00Added an answer on June 17, 2026 at 1:58 pm

    java.lang.ClassNotFoundException: socketchatclient.Message

    It means you are trying to deserialize a class you don’t have. Most likely the code on your client is different to that on the server and the client has serialized a class it has but unless the server also has this class in the same package it cannot deserialize it.

    I suggest you have a common module for serializable objects and both the client and server share to ensure the same classes are available at both ends.

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

Sidebar

Related Questions

This is my thread: public void run() { Log.d(ConnectionThread,Starting Server Connection); try { while(isThereActivityRunning())
Server has created a socket and bound to a port and started a thread
I want to run a thread pool on server side & want to show
I have used Thread Pool for New IO server design . I have used
My server database took too long to run two sql queries by separate thread.
i try creating client-server app using socket. i already succeed doing that with the
Given this code : package db; import java.sql.*; public class Main { public static
I have this structure in my program: class Node0 private Server server; ... public
~~~~~@debian:~/Workspace/SEPM1$ java -cp lib/hsqldb.jar org.hsqldb.server.Server -database.0 mydb -dbname.0 SEPM1 [Server@46f5c8fb]: [Thread[main,5,main]]: checkRunning(false) entered [Server@46f5c8fb]:
I have a game server that spawns a thread for each client with forkIO.

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.