Greg's Blog

helping me remember what I figure out

Free Version and Loading Jar Files

| Comments

The free version of BlueDragon sadly has no option for loading additional jar files such as jTidy or log4J at startup or by adding them to server the classpath. However thanks to Phil Cruz’s post to the NewAtlanta mailing list and Spike’s post on his blog there is way round this slight annoyance. Below is the code for loading jTidy from a relative path, which quite frankly pleases me no end!! <cfscript> pathToTidy = “/your/Path/To/Tidy.jar”; // Create an instance of java.net.URL for passing to the URLClassLoader URLObject = createObject(‘java’,’java.net.URL’); // Initialize the object with the jar file URLObject.init(“file:” & pathToTidy); // Create an Array and add our URLObject to it arr[1] = urlobject; // Create and the URLClassLoader and pass it the array containing our path loader = createObject(‘java’,’java.net.URLClassLoader’); loader.init(arr); // Use our new class loader to load the Tidy class tidy = loader.loadClass(“org.w3c.tidy.Tidy”).newInstance(); </cfscript> <cfdump var=”#tidy#” /> You can see it in action here