The same object is defined twice in different packages:
packageX/Object1.java
and
packageY/Object1.java
[Background: packageX is part of a webclient service, getting objects from a server. packageY is a java client using the objects retrieved by this webclient service].
A function from packageX returns Object1, and the compiler throws an error when I try to use this object as an Object1 from packageY (which I can understand).
=> Is mapping packageX/Object1.java to packageY/Object1.java my only option? Or do I miss something?
You appear to be missing something. Java makes things easier on the programmer by letting you use the "shorthand" of just a class's short name if you're in the same package or if you
importthe class, but each class's real name is its fully-qualified class name. In your case, you don't haveObject1defined twice, you have one class namedpackageX.Object1and another unrelated class namedpackageY.Object1. If you try to use both in the same scope, you have to specify the entire class name for at least one of the variables:There's no way to "map" from one to the other besides converting between them like you would between any two other classes that didn't have similar names.
Most likely, you should be using the same implementation in both the server and client sides. You're talking about "Web services", but this is generally only an issue if you're using Java serialization, not JSON.