We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentLibraries,  Tool Development › How to build libraries with imported dependencies
Page Index Toggle Pages: 1
How to build libraries with imported dependencies? (Read 1245 times)
How to build libraries with imported dependencies?
Mar 11th, 2009, 9:03pm
 
Question: how can I build a Processing library that uses other libraries as imports? This apparently simple thing is defeating me.

I'm attempting to create wrapper-libraries for a couple of existing libraries out there, the Jung library -

http://jung.sourceforge.net/

and some classes from geotools. My goal is to allow Processing users (and myself) easy access to some elementary parts of network analysis and mapping e.g. importing shapefiles, creating quick 'small worlds' etc.

Problem: I've been defeated immediately, I think by my IDE and classpath ignorance. Can anyone advise?

I *want* to be able to do the following:

* create the wrapper library, using e.g. Jung libraries as imports
* create some wrapper methods in that library that a sketch can access

I'm doing this with two projects in Netbeans: one is the library, another is a Netbeans version of Processing (i.e. using

public static void main(String args[]) {
       PApplet.main(new String[]{"package.Main"});
   }

All very well, having followed the library how-to. But it doesn't work when I attempt to call a method in the library that uses e.g. the Jung imports - there's a noclassdeffounderror. This is - I suspect - because I'm trying to test the wrapper library from within Processing and (in Netbeans at least) importing another project does *not* import its imports.

The problem is fixed if I include all the Jung jars in the Processing folder - but I need those dependencies to, ultimately, be wrapped in a single library. Is that something I should just do when I've finished the library - package it all in the correct way, and it'll then work in Processing without having to include all the imports in two places?

I'm presuming this must be a pretty common problem, but I'm flummoxed. Any suggestions would be very gratefully received. And apologies: I'll be writing to the Netbeans list as well, but I figured a Processing library writer might have come across this specific problem, i.e. wanting to write a library that uses imports at the same time as testing it in Processing in an IDE.

Cheers,

Dan
Re: How to build libraries with imported dependenc
Reply #1 - Mar 11th, 2009, 9:54pm
 
The only real way to do such a thing is the same way Processing does OpenGL, in the opengl library folder there's the processing library, *and* the JOGL libraries.

So to wrap it all up in a way you can just make it available to people you'll have to include all the jar files for the other libraries in the download really, so you'll have:
<Sketchdir>/libraries/yourLib/library/yourLib.jar and <Sketchdir>/libraries/yourLib/library/jung.jar etc etc.

You'd have to double check however that those libraries allow that in their license. If not, then the only option is providing instructions on how to get those libraries, and to unpack them into your library's directory.
Page Index Toggle Pages: 1