Search code examples
javaandroidsocketspackageclassnotfoundexception

ClassNotFoundException Package Name, Java


I'm trying to send an object from my android phone to my pc with sockets and ObjectOutputStreams. I have a object "Network" which I am trying to send. The two classes are identical on bot android and pc, except for the package thing. On my pc, I dont have a package name (I don't need to?) and on the Android I have a package name (Which I can't delete without errors). So I guess I get the error because the program on the pc cant find the class/object because the package name is invalid. So, how do I solve this? Thanks


Solution

  • The two classes are identical on bot android and pc, except for the package thing.

    So they're not identical.

    On my pc, I dont have a package name (I don't need to?)

    You need the same package name at both ends.

    and on the Android I have a package name (Which I can't delete without errors). So I guess I get the error because the program on the pc cant find the class/object because the package name is invalid.

    Correct.

    So, how do I solve this?

    Use the same class with the same package name at both ends.