example

A quick and dirty way to convert Java objects to and from XML

The process to marshal or serialize an object to XML can differ greatly from language to language and implementation to implementation. Even within a single language, like Java, there are multiple ways to go about it. I happened to stumble upon this one the other day and thought it was pretty straight forward. This example contains two classes XMLExample.java and Example.java. We will use the functions in XMLExample.java to convert Example.

Dynamically load a jar at runtime

A short post but I figured I would throw it up here before I lose my code. There are a couple of different ways that you can load jar’d code at runtime but here is a simple solution that I found to work very easily. File myJar = new File("myJar.jar"); URL url = myJar.toURI().toURL(); Class<?>[] parameters = new Class[]{URL.class}; URLClassLoader sysLoader = (URLClassLoader)ClassLoader.getSystemClassLoader(); Class sysClass = URLClassLoader.class; try { Method method = sysClass.