How to include java or xml code in a post or reply?

I have looked around, but so far no luck.

You can use markdown formatting when posting here. Take a look at this documentation: http://commonmark.org/help/

if you want to format code, use the ``` character three times.