1

I tried to import commons-io-2.6.jar and commons-lang-2.6.jar (Available here) into a Processing sketch.

I put these jars in the libraries folder located at the root of my Processing, but Processing didn't recognize my imports:

import commons-lang-2.6;
import commons-io-2.6;

How do I import an external jar like Apache in Processing?

6
  • Can you add link to the Processing? Commented Apr 30, 2019 at 21:14
  • 1
    Hi, welcome to SO. Please review carefully before approving someone else's edit. Also to @AmitVujic, may I politely point out that the edit feature should only be used to improve the readability and clarity of the post. And when you do use it, please make sure the post after edit reads better. You must use comments for everything else (Answers for answers ofc.) Commented Apr 30, 2019 at 23:00
  • @Anthony Please compare existing text with my edit - you will agree that after my edit readability and clarity is improved. Commented May 1, 2019 at 1:03
  • 1
    @AmitVujic I understand you are trying to add context to bring more sense to the question, but this is improving the quality of the question rather than readability. If something reads: I don't understand why this happens, so what can I do? Can anyone help me? I really need help on this. I can't solve it., and you reduce it to How can I solve this?, this is an example of improving readability. Suggestions on quality improvement should be placed in comment area and let OP revise the question. This prevents edits that deviate from the original intent of the post. Commented May 1, 2019 at 1:30
  • @Anthony I got you - but anyway first sentence remains confusing. Someone willing to help will lost patience on second sentence. However - I'm ok with yours comment. Commented May 1, 2019 at 1:36

1 Answer 1

1

These import statements don't look valid to me:

import commons-lang-2.6;
import commons-io-2.6;

Import statements should reference packages or class names, not jar files. You probably want something like this:

import org.apache.commons.lang3.StringUtils;

With this import statement, you could then use the StringUtils class in your sketch.

By the way, the easiest way to add a jar file to a sketch is to drag it onto the Processing editor directly. Processing handles putting the file in the right place for you, so you don't have to manually do it. Shameless self-promotion: here is a tutorial on using libraries in Processing.

Sign up to request clarification or add additional context in comments.

1 Comment

Ok thanks. Finally, I understand my mistake. My folder that contains my jar & my jar didn't have the same name. ..\Processing\libraries\<name>\library\<name>.jar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.