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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:32:34+00:00 2026-05-22T15:32:34+00:00

I have a java server that sends some data through a socket to a

  • 0

I have a java server that sends some data through a socket to a client developed in android.
The data that sent is serialized…and at the client side when trying to read from the ObjectInputStream I get the following error:

 java.lang.ClassNotFoundException: servers.Coordinate    
 at java.lang.Class.classForName(Native Method)
 at java.lang.Class.forName(Class.java:237)
 at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:2604) 
 at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1860)
 java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:840)
 at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2080)
 java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:943)
 java.io.ObjectInputStream.readObject(ObjectInputStream.java:2299)
 at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2254)
 at com.Server_1.ClientThread_special.run(ClientThread_special.java:30)
 at java.lang.Thread.run(Thread.java:1096)
 Caused by: java.lang.NoClassDefFoundError: servers.Coordinate
 Caused by: java.lang.ClassNotFoundException: servers.Coordinate in loader dalvik.system.PathClassLoader@43d02e18
 at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)

Now here is my code on the server side:

clientSocket = serverSocket.accept();
        System.out.println("S-a conectat clientul de monitorizare!");


        os=new ObjectOutputStream(clientSocket.getOutputStream());
        try{
        while(true){
            coord=(Coordinate)queue.take();
            System.out.println(coord.getLat());
        os.writeObject(coord);

        os.flush();

        }
        }
        catch(Exception e)
        {
            e.printStackTrace();

        }

On the client side I have this:

public void run() {

    try {
        InetAddress serverAddr = InetAddress.getByName(serverIpAddress);

        Socket socket = new Socket(serverIpAddress, serverPort);

        is=new ObjectInputStream(socket.getInputStream());



            try{
                while(!stop){

            coord=(Coordinate)is.readObject();

            System.out.println("Date de la clientul de monitorizare:"+coord.getLat());

            }

            }
            catch(Exception e)
            {
                e.printStackTrace();
            }

        is.close();

    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

And here is my serializable class I have it both on the client side and in the server side:

 public class Coordinate implements Serializable{

  private final double lon;

  private final double lat;

  private final int workerId;



  public Coordinate(double lat, double lon, int workerId) {

    this.lat = lat;
    this.lon = lon;

    this.workerId=workerId;
  }

  public double getLon() {
    return lon;
  }

  public double getLat() {
    return lat;
  }
  public int getwId(){
      return workerId;
  }


}

An instance of this class is what I’m sending through the socket.


EDIT:

on server I have the following :

package servers;

import java.io.Serializable;

public class Coordinate implements Serializable{

  private final double lon;

  private final double lat;

  private final int workerId;



  public Coordinate(double lat, double lon, int workerId) {

    this.lat = lat;
    this.lon = lon;

    this.workerId=workerId;
  }

  public double getLon() {
    return lon;
  }

  public double getLat() {
    return lat;
  }
  public int getwId(){
      return workerId;
  }


}

on the client side I have the following:

package com.Server_1;

import java.io.Serializable;

public class Coordinate implements Serializable{

  private final double lon;

  private final double lat;

  private final int workerId;

  public Coordinate(double lat, double lon, int workerId) {

    this.lat = lat;
    this.lon = lon;

    this.workerId=workerId;
  }

  public double getLon() {
    return lon;
  }

  public double getLat() {
    return lat;
  }
  public int getwId(){
      return workerId;
  }


}

I don’t understand how could I change the package to be the same on both of them!!!!!!

  • 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-22T15:32:34+00:00Added an answer on May 22, 2026 at 3:32 pm

    The package name of the class must be the same on the server and the client. I would also add serialVersionUID to the class. Implementing Serializable

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

Sidebar

Related Questions

I have a java socket server that sends an Animal object to the Flash
i have a server - client application that runs on java 1.3; i want
I have a simple ChatClient that sends data to a Server. In order for
I am developing an Android App that gets some data from a web server,
I have a java application that stores some GPS data in a strange format:
I implemented on Android a small application that sends through a socket connection strings
I have a client on Android and server on c#. The client sends messages
I have a very simple Java RMI Server that looks like the following: import
I have a server written in Java that runs as a Windows service (thanks
I have a client-server application written in Java using CORBA for the communication. The

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.