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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:54:04+00:00 2026-05-27T04:54:04+00:00

I am trying to send an object in java over a physical network (not

  • 0

I am trying to send an object in java over a physical network (not over localhost) but it seems I have something wrong.

The interface to the object (client and server have this):

public interface distributable extends Serializable {

      public void test();
}

The Object I am trying to send (only server has this):

class ObjectToSend implements distributable {

       public ObjectToSend() {
       }

       public void test() {
            system.out.println("worked!");
       } 
}

Server:

private ObjectToSend obj = new ObjectToSend();

obj_out_stream.writeObject(obj);
obj_out_stream.flush();

Client:

private distributable ReceivedObj = null;

try {
       ReceivedObj = (distributable) obj_in_steam,readObject();
} catch (ClassNotFoundException e) {
       System.err.println("Error<w_console>: Couldn't recieve application code!");
} 
ReceivedObj.test();

Everything was working when the ObjectToSend class implemented Serializable and I wasn’t using an interface because all my classes were in one directory so the client ‘knew’ about the object. Now I want it to work across a physical network so the client only has the interface to the object. It seems that client can not receive the object as the exception is thrown every time.

  • 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-05-27T04:54:04+00:00Added an answer on May 27, 2026 at 4:54 am

    As the other answers suggest, the Client also has to know the class of the object you want to send.

    Usually, one creates three packages/projects for such a classic client-server example:

    Common: Code that is used by client and server; the class definition of the objects you want to send from the server to the client belongs here

    Client: All code only the client needs to know about

    Server: All code only the server needs to know about

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

Sidebar

Related Questions

I have an applet trying to send java serialized object to a servlet (hosted
I am trying to send an anonymous object over a web service. Is there
I'm trying to send an email in Java but when I read the body
I'd appreciate any help on this... I have an Object I'm trying to send
I am trying to send a serialized Java object from a client to a
i'm trying to write a small java class. I have an object called BigNumber.
im trying to send rest api Users.getLoggedInUser i have all the secret session and
I am trying to send an email from a site I am building, but
For quite awhile I have been trying to make a simple game in Java
I want to create a Java File object in memory (without creating a physical

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.