Both Canon and Nikon provide SDKs to remotely control their cameras. I haven't used either, but briefly looked at Canon's description. It looks like they provide C libraries that can be used in Microsoft's development environments on Windows or XCode on the Mac.
Again, I haven't used these, but if you are using Java instead of a variation of C you could probably tie these into your software directly using JNI.
If you aren't using one of these platforms to develop your software then it's very likely that you could use the libraries provided to develop your own command line utilities.
I just googled "Canon camera SDK" and the first link that came up got me to Canon's SDK site.
Good luck.