Hi,
The ODK2 server, Sync Endpoint, has a REST API that you could call to implement your program (link to doc). In addition to the API, we also have a Java library, sync-client, that makes it easier to work with the API. We would recommend you use the library instead of working with the API directly.
Some examples of programs that consume the Sync Endpoint API: