Eclipse setup and Processing core.jar for Libraries

Any advice for people who have used Eclipse with processing (especially for Library development) greatly appreciated.

I’m curious about best practices – specifically, how you connect core.jar to Eclipse, and how/if that should be checked in to version control (e.g. github) when developing a Processing Library.

The issue: I’m an inexperienced Eclipse user, but I’m a bit put off that when I follow the Processing Library template instructions, Eclipse writes an absolute local path into my .classpath file, including my username (not portable). I’m trying to decide whether to 1) exclude the .classpath from the new library repository, or 2) leave it in but unconfigured, or 3) configure it into a relative path with something more portable like a path variable (like WORKING_DIR)… or something else?

I looked over the Basics and Guidelines again, then read the Processing Library Template documentation, and it says:

Locate 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 libs folder.

and later

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 your 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.

If you follow the instructions and copy core.jar into yourworkspace/libs, then select it as Add External JAR, then Eclipse does something like this in the .classpath:



Here are some example I have found of what established libraries are doing.

  1. The grafica library follows the Template instructions and checks in the .classpath – so it contains path="/home/jgracia/admin/eclipse-libs/core.jar"
  1. The Picking Library originally had one of these local paths that you get by following the Template instructions – path="/home/nico/workspace/libs/processing2/core.jar" – but then stripped it back out.
  1. PeasyCam has a generic .classpath – not sure how / if Processing is included in the working project outside build.xml /
  1. Timing Utils just doesn’t include any of it – .classpath, .project, etc., and they aren’t included in a .gitignore. Perhaps the library project wasn’t developed in Eclipse at all.

  2. Drop is the same way – no Eclipse project files or ant build files

  3. MostPixelsEver points to a root (?) directory called /processing-core/ – so does Box2D


I didn’t find any existing library examples of what I would first think to do, which is:

  1. myProject > Properties > Resources > Linked Resources > Path Variables > New > WORKSPACE_LOC
  2. myProject > Properties > Java Build Path > Add Variables > WORKSPACE_LOC > Extend > libs/core.jar

This creates a config line like this:

<classpathentry kind="var" path="WORKSPACE_LOC/libs/core.jar"/>



Hi Jeremy
I am not an expert in Eclipse. I can provide a suggestion why some libraries don’t include the core.jar. I would bet they built the library via CLI. How does it work? You provide the proper instruction to build your library making sure you define your classpath properly aka. pointing to a location where you can find your core.jar file. If this file changes location in your computer, then you will need to adjust your classpath manually next time you build the library. Is that easy. Now, after I build a library, I do not need to “build” the jars again. I place the generated jar (my library’s jar) into processing-sketch-path/libraries folder (as described in the library-guidelines or overview) and then I can access the library from any sketch in my PDE.

Now, in eclipse I can see that they want to setup a workspace that is independent of any changes or updates that your computer goes through. For instance, if your core.jar library that is used to run a PDE session lives outside of eclipse (it should), then any updates to that library would not “corrupt” your workspace as the workspace has a copy of the jar library to run your project. Yes, I can see this is redundant and I am willing to bet it is the way it was designed. You have always a working workspace but now you are responsible to maintaining two versions of the core library. Not the way I would do it and it seems that is not the way that you want either.

Related to Shifman’s way of doing things… I am willing to bet that, bc he is using a mac, he is probably using soft links to make the core.jar library available to those libraries. I have seen this is an approach available to linux-like systems and an easy way to keep multiple versions of a software available in a machine. For instance, you could soft-link your java master folder to jdk-1.6 or jdk-1.8 if you wanted to switch between different java versions in your (linux) computer. You are not moving or creating duplicate files but you are just creating a link that points to those resources.

In short, if I were to create a library, I will do it via CLI and then I provide a readme with the cli commands. Whoever wants to build the library, he/she needs to setup the classpath properly. It is not difficult and that is why I would not include the core.jar as part of the library. However, this probably applies to small source code. I might use eclipse if I were building a larger project.

Notice that if you are using P3D in your library, I believe you need to include other libraries beside the core.jar. If you export a simple pde example, you can see those extra jar files in the generated export/ folder under the libs folder (I think). I just thought of mentioning this as you might need to keep track not only of core but also of these jar files.

Looking forward to hearing comments from other users.