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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:31:41+00:00 2026-06-09T10:31:41+00:00

I am working on a simple client/server program and for now all it is

  • 0

I am working on a simple client/server program and for now all it is supposed to do is send an object from the client to the server on connection, then send an object from the server containing a response.

My object is supposed to send a username and password. Yes, I know there are other ways of authenticating a TCP connection, but this is a test to help me get my feet wet in networking with java.

My object is written as follows:

   import java.io.Serializable;

public class AuthAccount implements Serializable{
    private static final long serialVersionUID = -8918729105550799244L;
    private String username;
    private String password;

    AuthAccount(String user, String pass){
        username = user;
        password = pass;
    }
    String username(){
        return username;
    }
    String password(){
        return password;
    }
}

Socket connection is successful, but it fails on this line (oos is ObjectOutputStream):

System.out.print("Sending login object to server...");
oos.writeObject(new AuthAccount("user", "password"));
System.out.println("Done!");

I keep receiving the error:

java.io.NotSerializableException: AuthAccount

I have tried the AuthAccount test class using char[] username = new char[30]; so as to have a fixed size object. I am more of a C++ guy, but java made sense to me for this project.

  • 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-09T10:31:43+00:00Added an answer on June 9, 2026 at 10:31 am

    You must be using an old version of your build because

    public class Main {
        public static void main(String... args) throws IOException, ClassNotFoundException {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(new AuthAccount("u", "p"));
            oos.close();
    
            ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
            Object aa = ois.readObject();
        }
    }
     class AuthAccount implements Serializable{
        private static final long serialVersionUID = 1;
        private final String username;
        private final String password;
    
        AuthAccount(String user, String pass){
            username = user;
            password = pass;
        }
        String username(){
            return username;
        }
        String password(){
            return password;
        }
    }
    

    runs without error.

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

Sidebar

Related Questions

I'm working on a simple client/server application that uses sockets for all the communications.
I have been working on a (relatively) simple tcp client/server chat program for my
I'm working on a simple client side interface where I have a jQuery object
I have a simple programs for socket client and server its not working over
I am working on a simple client-server project. Client is written in Java, it
I'm currently working on a simple client/server file synchronization . For this, client and
I'm a novice/beginner programmer having problems getting some simple client/server C code working. My
I'm working on writing a very simple client/server application as an excuse to start
I am building a simple client-server program , I have in main : FTPClient
I'm trying to get a simple send and receive UDP program working, but I'm

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.