Setting up an eclipse project with the processing 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. This information and more can be found at dev.processing.org/libraries.
- Download the latest Eclipse template from download page.
- Don't unzip the .zip file yet, some systems automatically unzip downloaded zip files. Either deactivate this option when downloading the library-template or re-zip all files and folders included inside the library-template folder.
- 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, see image below. If folder libs does not exist yet, create it (in case you can't find the core.jar file see Where is core.jar below).
- Confirm the setup with "finish".
- Open the "resources" folder inside of your java project and double click the build.properties 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 (if a GUI like build configuration window appears inside your editor, switch to text mode by clicking on the 'build.properties' button at the bottom of the editor window). Edit the properties file, make changes to items 1-5 so that the values and paths are properly set for your project to compile. Please read the comments for more detailed instructions. A path can be a relative path or absolute. (1-4 are settings for compiling your project. 5 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.properties 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.
Where is core.jar
the core.jar file for osx users is contained and located inside the Processing application's package content. How to get there?
- navigate to your Processing application, right click (or control+click) onto the processing icon.
- select 'Show Package Contents'
- navigate to Contents → Resources → Java and copy core.jar to a location from where you can easily access it with Eclipse e.g. ~/Documents/workspace/libs.
How to distribute a library
To distribute your library please refer to the guidelines.
I cannot find the core.jar file. This guide is a lie!!!
not sure where you see a lie here, the instructions above tell you explicitly where to put the core.jar file and how to add it to your classpath. In order to build your own library a bit of processing's file structure and functionality definitely comes in handy here. the core.jar file is contained and located inside the Processing application's package content. How to get there?
i added Where to find core.jar to the HowTo above.
To cross-link Java and Processing APIs with your library's JavaDoc? (Last 2 lines in build.properties file)
javadoc.java.href=http://download.oracle.com/javase/1,5.0/docs/api/
javadoc.processing.href=http://processing.googlecode.com/svn/trunk/processing/build/javadoc/everything/
It says "An outline is not available" for the build.properties file. there's also no 'distribution' folder after building.
cheers