How to import a java library

edited May 2016 in Using Processing

Hey,

with a library source like this (https://github.com/apache/commons-lang - the actual .java files seem to be in /commons-lang/src/main/java/org/apache/commons/lang), how do I get it installed in my processing libraries folder for importing to any number of sketches?

I have tried creating a jar file from the source of that library and put it into a folder (/processing/libraries/lang3/library/lang3.jar) and it showed up in the import menu, but nothing got imported.

How can I import these kind of generic java library sources to processing?

Tagged:

Answers

  • edited October 2014

    You can find the pre-built jar here: http://commons.apache.org/proper/commons-lang/download_lang.cgi

    You should probably use eclipse if you want to do this sort of thing.

  • _vk_vk
    edited October 2014 Answer ✓

    from:

    https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library-[DRAFT]

    Another example: you want to use the Apache Common Collections library, which is a plain Java library (ie. not designed for use with Processing). The zip file contains a folder named commons-collections-3.2.1 with various files in it, including one: commons-collections-3.2.1.jar

    You have to create the libraries/ApacheCommonCollections/library folder (the middle name can vary, but must have only letters and numbers) where you put the jar file renamed along the folder name (here, ApacheCommonCollections.jar, then).

    Alternatively, if you need this library for only one sketch, you can just drag'n'drop the jar file on the PDE, it will put it in a folder named code in the sketch folder (you can also create the folder manually and put the jar file there yourself). This also works, of course, for regular Processing libraries. This solution isn't optimal if you plan to use the library in several sketches, as it will duplicate the library, taking up space and making difficult a possible upgrade.

Sign In or Register to comment.