Can I use Java API in Processing?

I'm use to working with the Java API. Is there an API for Processing? If not, is there way for me to make use of libraries from the Java API in my Processing code?

In particular, I'm hoping to use a library that implements common data structures (Linked List)

Answers

  • Processing itself is a framework API set above Java.
    And since we got Java, we can use most of its API too.
    And by extension, most API from 3rd-aprty libraries!

  • How can I include the libraries? Would I just import it as I would a processing library? Would I need to download the library?

  • Usually it takes a bit of structure reworking to get Java libs to work correctly in processing. generally this structure works:

    Processing > libraries > (lib name) > library > (lib name).jar

    Open up a processing specific library to see the structure it uses to find out how to structure it.

    For the import part, sometimes it's necessary to duplicate and rename the .jar to .zip and unzip it, then you can see the correct import string. For example it might be something like this:

    import com.libname.libraryclassname;

    hope this helps! ak

  • "I'm hoping to use a library that implements common data structures (Linked List)"
    They are already in standard Java, actually.

  • edited January 2014 Answer ✓

    Although I'd recommend ArrayDeque rather than LinkedList performance-wise.

    http://docs.oracle.com/javase/7/docs/api/java/util/ArrayDeque.html
    https://stackoverflow.com/questions/6163166/why-is-arraydeque-better-than-linkedlist

    Unless of course you'd need direct index access and/or remove current iterated object! :ar!

Sign In or Register to comment.