I recently did a gig for a client for the same requirement…the samples provided by SAG helped me a lot. If you install UM, you will see these samples under %installDir%\UniversalMessaging\java\examples. There are samples in there that creates a connection to UM from Core Java.
For your requirement i would recommend looking at %installDir%\UniversalMessaging\java\examples\com\softwareag\um\tools\JMSAdmin folder CreateConnectionFactory.java.
#Universal-Messaging-Broker#Integration-Server-and-ESB#webMethods