首页 > 未分类 > 【翻译】Processing库的手动安装
2018
04-04

【翻译】Processing库的手动安装

【翻译】Processing库的手动安装 - 第1张  | Processing编程艺术

网上对于手动安装库的讲解挺少的,主要是针对一些特别情况作出的解决方案,但是如果遇到的问题比较“小众”,那就很难找到有效的帮助,为了方便安装库的过程中遇到问题的人,看英文文档有困难的人,我翻译了一下官网的安装教程

原文地址:https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library

Install with the “Add Library…” tool

使用“添加库文件”工具安装

For Processing versions 2.0 and up, add contributed libraries by selecting “Add Library…” from the “Import Library…” submenu within the Sketch menu. Not all available libraries have been converted to show up in this menu. If a library isn’t there, it will need to be installed manually by following the instructions below.

 

对于Processing 2.0以上的版本,通过选择“速写本”菜单中“引用库文件(Import Library…)“下的子菜单“添加库文件(Add Library…)”来添加第三方库。但是并不是所有可添加的库都被被显示在这里。如果你想要的库不在这,那就需要你根据以下的教学来手动添加。

 

 

Manual Install  手动安装

Prior to Processing 2.0, it was necessary to add libraries manually. Only follow the Manual Install instructions here if you are using an older version of the software or if the library you want to add isn’t included in the “Add Library…” list mentioned above.

在Processing2.0之前经常需要手动添加库。如果你是用的是老版本的软件或者你想要的库并没有在“添加库文件”清单中出现,你就需要根据以下教程来手动安装。

 

Contributed libraries may be downloaded separately and manually placed within the libraries folder of your Processing sketchbook. As a reminder, the sketchbook is where your sketches are saved. To find (and change) the Processing sketchbook location on your computer, open the Preferences window from the Processing application (PDE) and look for the “Sketchbook location” item at the top.

第三方库能够在各种零散的地方下载到,并且需要手动添加进你的Processing速写本中的库文件夹。需要注意的是这个“速写本”是你的文件默认的保存地址。要找到(或者修改)你电脑上这个Processing速写本的位置,你需要打开Processing并且在“文件”菜单下打开“偏好设定”窗口,在这个窗口的顶端有一个“速写本位置(Sketchbook location)”

Copy the contributed library’s folder into the libraries folder at this location. You will need to create the libraries folder if this is your first contributed library.

把第三方库的文件夹复制进这个这个地址中的库(libraries)文件夹。你第一次添加第三方库的时候有可能需要自己创建一个“libraries”文件夹。

By default the following locations are used for your sketchbook folder. For Mac users the sketchbook folder is located inside ~/Documents/Processing. For Windows users the sketchbook folder is located inside folder Documents/Processing.

下面是默认的速写本文件夹地址:

Mac用户的速写本文件夹地址位于该文件夹中:

~/Documents/Processing

Windows用户的速写本地址位于该文件夹中:

Documents/Processing.

Let’s say you downloaded a library with name theLibrary. Then the folder structure of this library inside the libraries folder should look like the one below. The top folder of a library must have the same name as the .jar file located inside a library’s library folder (minus the .jar extension):

Documents

Processing

your sketch folders

libraries

theLibrary

examples

library

theLibrary.jar

reference

src

现在把你下载的库称作“这个库”。“这个库”文件夹在“libraries”文件夹中的结构应该是像下面这个样子。最顶端的library文件夹的名字必须与“这个库”文件夹中的library文件夹中的.jar文件夹同名。(当然要去掉.jar这个扩展名)

Documents

Processing

your sketch folders

libraries

theLibrary

examples

library

theLibrary.jar

reference

src

 

 

Some folders like examples or src might be missing. After a library has been successfully installed, restart Processing application.

一些诸如“examples”或者“src”文件夹可能会不见,可以在这个库成功安装后再重启Processing。

 

 

Still having trouble?  仍然有问题?

In some cases the top folder of a library does not exist after extracting from the downloaded zip file. In this case, the top folder must be created manually and given the same name as the .jar file inside folder library. After creating and renaming the top folder, move all extracted folders from the zip file in there.

有时候有些库在下载完解压会后可能会没有顶部文件夹,这种情况下,顶部文件夹就需要手动创建,并且以这个库文件夹里的.jar文件的名字命名。创建并重命名后,将解压出来的文件夹全部移动到这个文件夹中就行了。

 

For example, you downloaded the library otherLibrary, and the folder structure in the zip file looks like this:

examples

library

otherLibrary.jar

auxiliary.jar

documentation

src

举个例子,你下载了一个叫做“另一个库”的库,并且在压缩包中,这个库的文件夹结构是这样的:

examples

library

otherLibrary.jar

auxiliary.jar

documentation

src

 

 

You must create the otherLibrary folder in the libraries folder and copy the above folders inside, resulting in a structure like this:

Documents

Processing

your sketch folders

libraries

otherLibrary

examples

library

otherLibrary.jar

documentation

src

你必须在“libraries”文件夹中创建一个名叫“另一个库”的文件夹,并且将以上所述压缩包中的文件夹都复制进其中,结果应该是这样的:

Documents

Processing

your sketch folders

libraries

otherLibrary

examples

library

otherLibrary.jar

documentation

src

 

After a library has been successfully installed, restart Processing application.

当库被成功安装之后,重新启动Processing就行了。

Non-Processing Libraries 非Processing库

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

另一种例子:你想要使用java库Apache Common Collections(库的名字)(ie不适合Processing),这个压缩包有一个包含了各种文件叫做commons-collections-3.2.1的文件夹,这其中就有一个叫做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).

你需要这样进行创建文件夹:libraries/ApacheCommonCollections/library (中间的名字可以改变,但是只能用数字和字母)你可以将jar文件夹以此文件夹重命名并放置此处(上级,ApacheCommonCollections.jar,下级)

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.

或者如果你只需要在一个速写中使用这个库,你可以直接将这个jar文件拖拽至PDE中,他会被放进该速写文件夹中一个叫做code的文件夹里(你也可以手动创建这个code文件夹并且将jar文件手动放置进去)。当然,这对于普通的Processing库也管用。如果你想在几个速写中使用这些库,这可能不是一个好办法,因为它会重复添加库,增加占用的空间并且让升级变得困难。

 

 

注:

  1. Processing创作称为“速写(sketch)”,默认的文件存储位置被称为“速写本(sketchbook)”,速写本地址一般位于“我的文档”中(Mac的不清楚)。
  2. 库的手动安装很简单,有时候出问题可能是Top Floder(一个包含所有库文件的文件夹,总的文件夹,相当于库的大包装)顶文件夹的名字有问题,除了文中讲到的需要和库中的library文件夹里的jar文件同名外,还有可能有的库的library文件夹中没有jar文件,但是有一个压缩包,这时候名字与压缩包同名就行了。


最后编辑:
作者:DurianBomb
这个作者貌似有点懒,什么都没有留下。

【翻译】Processing库的手动安装》有 1 条评论

  1. 杨磊 杨磊 说:

留下一个回复

你的email不会被公开。