Yes, you could use a Java API to create our processes, although that might not be the best way to get started ;) (as it might be rather low-level). Usually, the easiest way to get started is using the Eclipse plugin (you can use the installer to get a working environment) and start using the graphical editor there (and you can see what it spits out as underlying XML as well).
An example of the API to create processes:
https://github.com/krisv/jbpm/blob/master/jbpm-flow/src/test/java/org/jbpm/process/ProcessFactoryTest.java
To be honest, this API probably needs some polishing to update it and maybe make it more BPMN2-focussed.
Kris