Cover | \ Build | \ Source | \ Bugs | \ Reference | \ Libraries |
|  |  |  |  | Overview \ Guidelines \ Template \ Basics

### Eclipse Library Template The following describe how to set up a Processing library project in Eclipse and build it successfully, and to make your library ready for distribution. Download the latest Eclipse template from here. Don't unzip the .zip file yet. Create a new java project in eclipse. from the menubar choose File → New → Java Project. Give the project the name of your library. Right-click (ctrl-click) onto the folder icon of your newly created project in the "Package Explorer" and choose "Import" from the menu that pops up. Select General → Archive File, click "Next" and navigate to the zip file you downloaded earlier in step 1. Confirm the archive with "Finish". Open your project's "Properties" window. Under "Java Build Path", select the "Libraries" tab and use "add external JARs" and add processing's core.jar to your build path. It is recommended that a copy of core.jar is located in your eclipse workspace in a folder libs. If folder libs does not exist yet, create it. Read the section below regarding where to find the core.jar file. Confirm the setup with "finish". Open the "resources" folder inside of your java project and double click the build.xml file. This file will be used to compile your library with apache ant. After double clicking the file, you should see its content in the eclipse editor. Edit the ant file, make changes to items 1-14 at the beginning of the file so that the values and paths are properly set for your project to compile. A path can be a relative path or absolute. (1-4 are settings for compiling your project. 5-14 are settings for the automatically generated html document.) From the menu bar, choose Window → Show View → Ant. A tab with the title ant will pop up on the right side of your eclipse editor. Drag the resources/build.xml file in there, and a new item "processingLibs" will appear. Press the play button inside the ant tab. BUILD SUCCESSFUL. The library template will start to compile, control-messages will appear in the console window, warnings can be ignored. When finished it should say BUILD SUCCESSFUL. congratulations, you are set and you can start writing your own library by making changes to the source code in folder "src". BUILD FAILED. In case the compile process fails, check the output in the console which will give you a closer idea of what went wrong. Wrrors may have been caused by Incorrect path settings in the build.xml file. Error "Javadoc failed". if you are on windows, make sure you are using a JDK instead of a JRE in order to be able to create the javadoc for your library. JRE does not come with the javadoc application, but it is required to create libraries from this template. After having compiled and built your project successfully, you should be able to find your library in processing's sketchbook folder, examples will be listed in processing's sketchbook menu. Files that have been created for the distribution of the library are located in your eclipse's workspace/yourProject/distribution folder. In there you find the web folder which contains the documentation, a zip file for downloading your library, a folder with examples as well as the index.html and css file. To distribute your library please refer to the guidelines. Source code If you want to share your library's source code, we recommend to use an online repository available for free at code.google.com or sourceforge.net. Adding core.jar and other .jar files to your classpath The core.jar file contains the core classes of processing and has to be part of your classpath when building a library. On Windows and Linux, the file is located in the Processing distribution folder inside a folder named "lib". On Mac OS X, right-click Processing.app and use Show Package Contents to see the guts. The lib folder is at Contents → Resources → Java → lib. For further information about the classes in core.jar, you can see the source here and the developer documentation here. If you created a "libs" folder as described above, put the libraries you need to add to your classpath in there. In the "Properties" of your java project, navigate to Java Build Path → Libraries, and click "Add External JARs". Select the .jar files from the libs folder that are required for compiling you project. Adjust the build.xml file accordingly. The libs folder is recommended but not a requirement, nevertheless you need to specify where your jar files are located in your system in order to add them to the classpath. In case a library depends on systems libraries, put these dependencies next to the jar file. For example processing's opengl.jar library depends on jogl hence the dlls (for windows) or jnilibs (for osx) have to be located next to the opengl.jar file. What is the difference between JDK and JRE? JDK stands for Java Development Kit whereas JRE stands for Java Runtime Environment. For developers it is recommended to work with a JDK instead of a JRE since more Java development related applications such as Javadoc. Javadoc is a requirement to properly compile and document a Processing library as described on the guidelines page. You can have both, a JDK and a JRE, installed on your system. in eclipse you need to specify which one you want to use. The JRE System Library This primarily affects Windows and Linux users (because the full JDK is installed by default on Mac OS X). It is recommended that you use the JDK instead of a JRE. The JDK can be downloaded from Sun's download site. Also see the Java webnotes which contain useful information about installation. To change the JRE used to compile your java project: open the properties of your project from the menu Project → Properties", select "Java Build Path" and in its sub menu, click on the "Libraries" tab. A list of JARs and class folders in the build path will show up. In this list you can find the JRE System Library that is used to compile your code. Remove this JRE System library. Click "Add Library..." In the popup window choose "JRE System Library" and press "Next". Select an alternate JRE from the pull-down menu or click and modify the "installed JREs". Confirm with "Finish" and "OK". Compiling with ant and javadoc Ant is a Java-based build tool. For more information visit the ant web site. Ant uses a file named `build.xml` to store build settings for a project. Javadoc is an application that creates an HTML-based API documentation of Java code. You can check for its existence by typing `javadoc` on the command line. On Mac OS X it is installed by default. On Windows and Linux, installing the JDK will also install the javadoc tool.

| Processing is an open project initiated by Ben Fry and Casey Reas |
| © Info \ Site hosted by Media Temple! |