How to get hex string from transaction in bitcoinj
A shorter version could be:

String hex = DatatypeConverter.printHexBinary(tx.unsafeBitcoinSerialize());


Where the hex converter used is standard at least since Java 7:

http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/DatatypeConverter.html