简体   繁体   English

如何在 Processing 中导入外部库?

[英]How can I import an external library in Processing?

I tried to import commons-io-2.6.jar and commons-lang-2.6.jar (Availablehere ) into a Processing sketch.我尝试将commons-io-2.6.jarcommons-lang-2.6.jar (可在此处获得)导入到处理草图中。

I put these jars in the libraries folder located at the root of my Processing, but Processing didn't recognize my imports:我将这些 jars 放在位于我的 Processing 根目录的库文件夹中,但 Processing 无法识别我的导入:

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

How do I import an external jar like Apache in Processing?如何在 Processing 中导入像 Apache 这样的外部 jar?

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.导入语句应该引用包或类名,而不是 jar 文件。 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.使用此导入语句,您可以在草图中使用StringUtils类。

By the way, the easiest way to add a jar file to a sketch is to drag it onto the Processing editor directly.顺便说一句,将 jar 文件添加到草图的最简单方法是直接将其拖到处理编辑器中。 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.无耻的自我推销:是一个关于在 Processing 中使用库的教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM