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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:58:14+00:00 2026-05-25T00:58:14+00:00

I’m developing an app where the phone (Android program) is the client trying to

  • 0

I’m developing an app where the phone (Android program) is the client trying to send data through a socket to a Java receiver program on my computer.

So far I’ve been able to send simple strings or whatever, but now I’m trying to send custom objects that I create. I should note that both programs are separate Eclipse projects, and I seem to be having trouble including the same custom class “Order” on the server side (even though I have Order.java in the src folder of the server project).

Some code, for reference:
Server:

private void run() throws Exception {

    ServerSocket mySS = new ServerSocket(4443);     

    while(true) {

        Socket SS_accept = mySS.accept(); 

        InputStream is = SS_accept.getInputStream();  
        ObjectInputStream ois = new ObjectInputStream(is);  
        Order order = (Order) ois.readObject();  

        if (order!=null){
            java.util.List<String> items = order.getOrders(); 
            int chair = order.getChair();
            int table = order.getTable(); 
            double price = order.getPrice(); 
            System.out.println("Table: "+ table + " || Chair: " +chair);
            for(String food: items) {
                System.out.println(food); 
            }
            System.out.println("Price: $"+price); 

        }  
        is.close();  
        SS_accept.close();  
        mySS.close();

}

And the relevant part of the client:

try {
        mySocket = new Socket(serverService.ipAddress, serverService.port);
        os = mySocket.getOutputStream();  
        oos = new ObjectOutputStream(os);  
    } catch(Exception e) {
        Toast.makeText(PlaceOrder.this, "Error - not connected to server.", Toast.LENGTH_SHORT).show(); 
    }

try {
                oos.writeObject(order);
                Toast.makeText(PlaceOrder.this, "Order Submitted!", Toast.LENGTH_SHORT).show(); 
                refreshOrderPage(); //refresh page, allow waiter to make more orders
                oos.close();  
                os.close(); 
                mySocket.close(); 
            } catch (Exception e) {
                Toast.makeText(PlaceOrder.this, "Error - not connected to server.", Toast.LENGTH_SHORT).show();
            } 

Any ideas why I’m getting this error when trying to send objects through sockets?

Thanks.

  • 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-25T00:58:15+00:00Added an answer on May 25, 2026 at 12:58 am

    You should probably set the serialVersionUID in the class, then build a jar with the shared classes and include that jar in both projects.

    However, given you are using different JVMs (Oracle and Dalvik) there’s no guarantee that the byte-level encoding is the same. You should either manually override the serialization using readObject/writeObject or use a different object encoding system that is guaranteed to be identical independent of the environment.

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

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have thousands of HTML files to process using Groovy/Java and I need to

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.