You didn't mention how you created the graph that you've shown an image of. If you're creating it programmatically, you can do the same using the Jena API: just create a model, create resources and add properties. The Javadocs for Jena are pretty thorough, and the Jena website has some tutorials.
In this case, however, I think the easiest course of action is to just write the graph using a human-readable-writable format like Turtle, and then to use Jena or another library to convert that to RDF/XML. In this case, you could write something like:
@prefix : <urn:ex:>
:JavaClass :belongsTo :Domain1, :Domain2, :DomainN ;
:hasMethod :Method1, :Method2, :MethodN .
If you're programmatically generating that, you might use a less abbreviated form, like:
<urn:ex:JavaClass> <urn:ex:belongsTo> <urn:ex:Domain1> .
<urn:ex:JavaClass> <urn:ex:belongsTo> <urn:ex:Domain2> .
<urn:ex:JavaClass> <urn:ex:belongsTo> <urn:ex:DomainN> .
<urn:ex:JavaClass> <urn:ex:hasMethod> <urn:ex:Method1> .
<urn:ex:JavaClass> <urn:ex:hasMethod> <urn:ex:Method2> .
<urn:ex:JavaClass> <urn:ex:hasMethod> <urn:ex:MethodN> .
In either case, you can use any number of tools to convert that into RDF/XML. E.g., with the rdfcat command line utility that comes with Jena, you could just do:
$ rdfcat -out RDF/XML-ABBREV data.n3
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="urn:ex:">
<rdf:Description rdf:about="urn:ex:JavaClass">
<belongsTo rdf:resource="urn:ex:Domain1"/>
<belongsTo rdf:resource="urn:ex:Domain2"/>
<belongsTo rdf:resource="urn:ex:DomainN"/>
<hasMethod rdf:resource="urn:ex:Method1"/>
<hasMethod rdf:resource="urn:ex:Method2"/>
<hasMethod rdf:resource="urn:ex:MethodN"/>
</rdf:Description>
</rdf:RDF>