AFAIK there was no such attempt. But it surely sounds interesting because there's no obvious solution 
G2 is written in PHP, and it's output is HTML and images.
We have an entry point, a embedding API, which is also in PHP.
But if there was an XMLRPC interface to or in parallel to our GalleryEmbed API, you could interact with G2 from an arbitrary application.
The idea would be to let G2 generate the HTML with its own templating engine and embed that HTML in your java (server) application.
Alternatively, you could do the whole templating yourself, but this is far, far more involving and no existing G2 integration works this way.
Perhaps you already know Gallery Remote (GR), a java applet / application which communicates with G2 with the GR Protocol.
There is also an early implementation of a G2 XMLRPC protocol, which implements only a few G2 API calls, but once it is done, it should encompass the whole G2 API.
If you have other ideas...it'd be very interesting to hear them.