Over the years I’ve created a lot of helper functions that I constantly copy between projects. This doesn’t feel very bullet proof of course so I wanted to merge all those functions inside a java library.
Processing Library Template
I started with the Processing Library Template and Shiffman’s tutorials. I got this to work but I found that Eclipse isn’t that user friendly, ran into errors in Eclipse but the build was still working and the whole starter template felt very complex for all kinds of stuff that I’m not going to use like documentation and publishing.
Using VS Code
I figured I wanted to keep things simple and moved to VS Code which has a Java toolkit built in. I created a small library, added processing.core as a library and exported it to a .jar file. But I’m now getting the error: “The library “Test” cannot be used because it contains the processing.core libraries.”
I tried googling it but I didn’t get any results. I got this error one time when I was using Eclipse and added the core.jar as a library instead of adding it to the classpath as an external jar.
Any pointers how I could make a small personal java library to work for Processing without using Eclipse?
I’m not an expert on making libraries, but I have made a couple small ones for processing using eclipse. I have found that the library template has some issues as well, so I do it more manually. It still works, but you won’t have features that you see in processing libraries, like descriptions and credits.
They way I do it is by making a new Java project, adding the processing core libraries as external jar files to the class path, then making packages and classes.
To use this as a library for processing, right click on the root folder for the project in eclipse, click on export, and export as a jar file. Then, go into your processing folder, go into the “libraries” folder, and
then make a folder with the same name as your jar file. In that folder, make a folder called “library”, then paste the exported jar file in there.
Relaunching processing will have it show up in the contributed libraries section.
Hopefully this is sufficient for what you want to do.
Hi Shwaa - thanks for the reply. I think I’m doing something similar in VS Code and I got actually something to work right now.
I came across this issue/pull request where my problem is further explained. I started a google search about 'excluding libraries jar build" in VS code and came across this feature when building:
During the build you can uncheck the core.jar - this fixed my problem. (see image)
Just like you described:
- I create a simple library inside of VS Code
- Build it to a .jar file and excluding the core.jar
- Manually move the .jar file to my library directory inside of Processing
The last step would be nice if I could do this automatically just like Eclipse. But this works for now
Can you please share the library? Is there a documentation?
Hi Chrisir, it’s a very personal library tailored to my needs with no documentation whatsoever. I won’t share it because it is bound to change and will be a bit hacky
Maybe I can create this project as a very simple Processing Java Library starter for VS Code if there is a need?