Contributed Libraries

This tutorial is an updated version of Section 12.3: Contributed Libraries. Processing now allows for a “libraries” folder inside your Processing sketchbook, which is a great deal more convenient than having your 3rd party libraries installed in the Processing application folder. Now, when you upgrade to a new version of Processing you don’t have to copy your libraries over.



As of the writing of this book, there are 47 contributed libraries, with capabilities ranging from sound
generation and analysis, to packet sniffing, to physics simulations, to GUI controls. Several of these
contributed libraries are demonstrated in this book’s examples. Here, we will take a look at the process of downloading and installing a contributed library.

Where to install them

First, locate where your Processing sketchbook. This is the default directory of all of your Processing sketches. On a mac, this will usually be:



/Users/Username/Documents/Processing



on a PC, it’s probably:



c:/My Documents/Processing/



If it doesn’t already exist, create a folder called “libraries” here. This is where you’ll install the 3rd party libraries. An example of a contributed library is one used with this book: SimpleML, a library for making asynchronous requests for raw data from web pages and/or XML feeds. You can download the library from this link.


How to install them

Step 1. Extract the ZIP file. This can usually be accomplished by double-clicking the file or with any decompression application, such as Winzip on a PC.



Step 2. Copy the extracted files to the Processing libraries folder. Most libraries you download will automatically unpack with the right directory structure. The full directory structure should look like this:



/Processing/libraries/simpleML/library/simpleML.jar



More generically:



/Processing/libraries/libraryName/library/libraryName.jar



Some libraries may include additional files in the “library” folder, as well as the source code (which is commonly stored one directory up, in the “libraryName” folder). If the library does not automatically unpack itself with the above directory structure, you can manually create these folders (using the finder or explorer) and place the libraryName.jar file in the appropriate location yourself.



Step 3. Restart Processing. If Processing was running while you performed Step 2, you will need to quit Processing and restart it in order for the library to be recognized. Once you have restarted, if everything has gone according to plan, the library will appear under the “Sketch → Import Library.”



What to do once you have installed the library really depends on which library you have installed. Examples that make use in code of a contributed library can be found in Chapter 18 (simpleML, "http://www.learningprocessing.com/tutorials/yahoo">Yahoo API) and Chapter 20 (Sonia, Minim).



(Note that the process for installing other contributed libraries will be identical, with the exception of filenames.)

  • kyle

    thank you!

  • Kleajmp Fidich

    thanks this saved my day!

  • Cshyg0516

    Hi i’m really depressed coz i’ve followed every steps about create “libraries” folder under sketch folder but still I can’t see 3rd library in Import Library..
    Why didn’t it appear ?? 

    ps : my library is for ‘opencv’.  

  • Lala

    This is very precise, thank you!

  • oamar

    help! i have created a folder caller libraries in “my documents” on my mac and pasted the folders inside it and it does not work. please help. 

  • Anonymous

    The folder “libraries” needs to be inside the Processing sketch folder.  On a mac this is usually /Documents/Processing/libraries

  • Info

     Tnkx.

    nveces.com

  • Idee17

    hey oamar you need to go into the folder called Processing then create a folder call libraries in there. after you do that your free to drop in the library that your missing

  • Davidamiel Design

    for me still not working I downloaded a library for generative design my path is : user/david/documents/Processing/libraries/generativedesign/library/01_P/P_1_2_1_01/P_1_2_1_01.pde ( no .jar inside)

  • shiffman

    something is wrong with the library itself.  it has to have a jar to work. that seems more like an example, not a library.

  • Mbk38

    hi! i have followed your steps. The tuio library is in users/myname/documents/processing and nothing shows up in import library or sketchbook. i have the same problem with my arduino that uses the same setup. I’ve restarted processing. I cant figure it out. Please help! 

  • Coconnell

    I love this app

  • Milodog

    dude, i dnt understand wht u r saying… its like another language

  • Spencerofusa

    it was the best thing in my life i want to do it every day

  • Shiriz

    Hi, hope someone can help me. I successfully installed OpenCV, and it showed up on my Sketch > Import Library. However, when I run my codes, it says: 
    “UnsatifisiedLinkError: hypermedia.video.OpenCV.capture(III)V”I am clueless why its not working. Any idea how to rectify the problem?

  • Jordan Stefanelli

    It doesn’t go in your sketch folder – it goes in the processing folder (where your processing application file is, either Processing.EXE for windows or Processing.APP for mac). I made this mistake as well.

  • http://www.facebook.com/laboeuf Chris Sullivan

    hey.. this may be a bit unrelated to the topic above but.. I was wondering if any of you can tell me why the Sonia (sound app) does not come up when i go to my sketch import library section.. please anybody help me with this.

  • shiffman

    Is the library installed in your libraries folder? The paths must be correct and the name of the JAR files must match the folder name. Sonia is rather out of date and may not be compatible with Processing 2.0. I would suggest using MInim.

  • George Profenza

    OpenCV connects to a bit of c++ code behind the scenes and you have an extra step (other than adding the Processing wrapper lib to Processing’s libraries folder): Installing the OpenCV framework (which I think it’s version 1.0), so for Mac: http://ubaa.net/shared/processing/opencv/download/01/opencv-framework.1.1.dmg and for Windows: http://sourceforge.net/projects/opencvlibrary/files/opencv-win/1.0/OpenCV_1.0.exe/download

  • philippe castellin

    p5 1.5.1 on mac OSX 1.6.8, java 6 : works fine

    i have downloaded p5 2.07b and tried to launch it

    it seems to launch, shows the first image and then quit

    same thing with 2.06…

    in the console window allways the same error message:

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] Exception in thread “AWT-EventQueue-0″ java.lang.NullPointerException

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at processing.app.contrib.ContributionManager.checkDeletions(ContributionManager.java:682)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at processing.app.Base.(Base.java:337)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at processing.app.Base.createAndShowGUI(Base.java:199)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at processing.app.Base.access$000(Base.java:46)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at processing.app.Base$1.run(Base.java:137)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.awt.EventQueue.access$000(EventQueue.java:85)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.awt.EventQueue$1.run(EventQueue.java:638)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.awt.EventQueue$1.run(EventQueue.java:636)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.security.AccessController.doPrivileged(Native Method)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.awt.EventQueue.dispatchEvent(EventQueue.java:647)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)

    29/12/12 14:48:45 [0x0-0x51051].org.processing.app[638] at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

    what is wrong???
    thanks in advance

  • philippe castellin

    i found myself the answer
    changing the authorizations for the libraries folder to “everyone reading & writing” and now p5 2.0b7 launches ok
    but i cannot understand why i had to do that ,as 1.5.1 runs without this change….
    i have seen that others users have the same problem
    hoping that it helps them!
    ph c.

  • Dan

    Hey there! Turtorial is great so far…
    But now i´ve got an other Problem with this string:

    String timestamp() {
    Calendar now = Calendar.getInstance();
    return String.format(“%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS”, now);
    }

    Allert is:
    Cannot find a class or type named “Calendar”

    Got any Idea ?
    thx

    Dan

  • Max

    Anybody founnd a solution to this already? I’m running into the same problem.

  • Max

    Found this in a different forum and it worked for me:

    Try adding the following import:

    import java.util.Calendar;

  • Scott

    I’m getting a 404 at GitHub from the SimpleML dl link. Can anyone provide a new address?

  • shiffman

    SimpleML is deprecated. You can do everything with new features in Processing 2.0. Sorry, update to the book is coming soon!

  • Scott

    The amount of free knowledge I’m getting from you means there’s no need to apologise! Thanks for getting back to me. Keep up the good work!

  • PJ

    Great tutorial, just what I’m looking for!
    One problem, when I try to run the processing code It says ‘no library found for simpleML’. I have the newest version of processing 2.
    I can’t even find the library in the Import library section.
    Any help would be great, thanks!

  • shiffman

    SimpleML is deprecated. You can do everything with new features in Processing 2.0. Sorry, update to the book is coming soon! https://github.com/shiffman/LearningProcessing/tree/master/chp18_data

  • PJ

    Thanks for you quick reply

  • KesterR

    My folder structure looks like this:

    C:UsersKesterDownloadsprocessing-2.1.1-windows64processing-2.1.1librariesJHeatChartlibraryjheatchart-0.6.jar

    but it’s still not working when I do import jheatchart.*; or Sketch>Import Library

    Any other clues please?

    Thanks!

  • shiffman

    jar name and folder name have to match

  • KesterR

    Thanks! Tried:

    C:UsersKesterDownloadsprocessing-2.1.1-windows64processing-2.1.1librariesjheatchart-0.6libraryjheatchart-0.6.jar

    (Closed and re-opened Processing in between.)

    Also tried

    import jheatchart.*;

    and

    import jheatchart-0.6.*;

    Still doesn’t work. Any other suggestions?

  • shiffman

    you can also put the jar file in a folder called “code” in the sketch itself for it to be accessible.

  • KesterR

    Also tried:

    C:UsersKesterDesktopDissertation1 sheep boidsboids3_2codejheatchart-0.6.jar

    Closed all Processing windows and re-opened.

    import jheatchart.*;

    import jheatchart-0.6.*;

    Sketch>Import library – not there

    Does JHeatChart just really not like me?! ;-)

  • KesterR

    More bizarrely, when I try the drag n drop method of importing a library, it says “Replace the existing version of jheatchart-0.6.jar?”.

    But it also says “No library found for jheatchart”! Which is it, Processing?!

    I just updated to Processing2.1.2 too, and tried again. No change.

    Thanks for your quick replies! Anything else I can try?

  • shiffman

    i don’t think you have the right import. it’s something like:

    import org.tc33.jheatchart.*;

    check the library’s documentation to be sure.