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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:18:40+00:00 2026-06-14T07:18:40+00:00

When I try to send this class through a socket, all I get back

  • 0

When I try to send this class through a socket, all I get back is NullPointException. How would I make it so that I do not get NullPoint Exceptions?

public class Hick implements Serializable{
public JTextArea jta;
public Hick(){
jta = new JTextArea();
}
}
  • 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-14T07:18:41+00:00Added an answer on June 14, 2026 at 7:18 am

    I tested it with the following code it seems to work fine…

    I would make sure that you can serialize the object locally first to rule out any potential problems. If you still can’t get it to load across the socket, then your socket code is at fault, not the serialization

    public class TestSerialisation {
    
        public static void main(String[] args) {
            new TestSerialisation();
        }
    
        public TestSerialisation() {
            ObjectOutputStream oos = null;
            ObjectInputStream ois = null;
            Wrapper out = new Wrapper();
            System.out.println("Before = " + out.dump());
            try {
                try {
                    oos = new ObjectOutputStream(new FileOutputStream(new File("Test.out")));
                    oos.writeObject(out);
                } finally {
                    try {
                        oos.close();
                    } catch (Exception e) {
                    }
                }
    
                Wrapper in = null;
                try {
                    ois = new ObjectInputStream(new FileInputStream(new File("Test.out")));
                    in = (Wrapper) ois.readObject();
                } finally {
                    try {
                        ois.close();
                    } catch (Exception e) {
                    }
                }            
                System.out.println("After = " + (in == null ? "null" : in.dump()));            
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
            }
        }
    
        public static class Wrapper implements Serializable {
    
            private JTextArea textArea;
    
            public Wrapper() {
                textArea = new JTextArea("I'm some text");
            }
    
            public String dump() {
                return textArea.getText();
            }
        }
    }
    

    Also make sure you are running compatible versions of Java and (if my memory serves me properly) you have compatible versions of the serialized object on both ends.

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

Sidebar

Related Questions

I've written this code to try and send a url as a post value
Hello i' ve this problem with unicode emails, when i try to send words
I'm using C++ with QT4 for this. And when I try to send large
I try to send a request to my server via GET, but qooxdoo sends
I want to send class data through the Scala RemoteActor API. I made a
My class contains a socket that connects to a server. Some of the methods
I implemented on Android a small application that sends through a socket connection strings
This has been asked once before but that didn't work for me at all.
Guide me through this exception. I have been trying to send a file from
i try to send private message to followers of a user who is already

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.