If I use Olingo4 libraries at client side (java), would they be compatible with ODATA 2.x services?
Thanks
The short answer is no.
The long answer is, Olingo or any other library is just an implementation of the OData Protocol. The version 4 of the protocol had breaking(read incompatible) changes, with the previous versions.
You can check out this link to get a list of all changes, including the incompatible ones in OData 4.
Now to be fully compatible, with both OData 2 and OData 4, you can read the OData-MaxVersion
header sent by the client and based on it, you can send the response accordingly.This will require you to have both odata 2 and odata 4 implementations(using Olingo 2 and Olingo 4 or something else) running on your backend.
On a personal note, if you are starting out today and don't have a strong reason to have two implementations, it's not mandatory for an OData v4 service to support a lower version client.
An OData 4 service may respond to V1-V3 clients with 4XX-level errors.