onar3d
YaBB Newbies
Offline
Posts: 32
Java help request by Mother developer
Jan 22nd , 2009, 12:30pm
Hi! In my efforts of further developing the Mother program (GPL host for VJing with processing sketches, have a look at www.onar3d.com), I’ve run into some trouble that the Java ninjas in this forum might be able to help me out with :) Briefly, what I’m looking for is a way to dynamically alter the location where the ClassLoader looks for new classes, preferable including looking within jar files. What my program does, is treat processing sketch .jar files as plugins. I instantiate the sketch using Class.forname(), to which I give a new URLClassLoader created with the path to the sketches jar file like this: URLClassLoader cl = new URLClassLoader( new URL[] {sketchPath.toURI().toURL()} ); This works fine for sketches that do not use external libraries (say toxi’s geomutils.jar for example), or sketches that have been exported from eclipse so that they include the libraries in the .jar file. However the Processing IDE does not pack sketches in this manner, and so when I load such a sketch in my program, I get a “java.lang.NoClassDefFoundError: toxi/geom/Vec3D” in the case where the sketch was using toxi’s geomutils.jar. What I would like is a way to programmatically, when my application is starting up, scan a user-defined folder with library jar’s, and make sure that the ClassLoader takes these into account. I’ll of course keep looking for a solution, and in the meantime I’d be grateful for any tips you may have! Thanks, Ilias B.