How to create a library from projects

hello, when creating a larger project, I ran into the problem that everything is in one project. I would like to create classes and use it in another project as a library. If there is such an opportunity in “Processing”, then tell me how to do it.


Take a look here:

Take a look at the use of tabs in the Processing IDE:

I have a number of files that I simply drag and drop into Processing sketch that contain methods and classes for reuse. These will be separate tabs.




Some hints

Hi @urlxd,

imo this is not really a processing question, but rather a java one…
Also don’t know what OS you are working on so assuming Windows by using processing java mode.
Further not knowing if you want to create a contributed library or only some function you want provide for yourself.

if first one, look here:

if the latter you can build a simple library depending on your java knowledge yourself.

Just a demonstration not a recommendation :slight_smile:

  1. create a directory structured for your java files and add some functionallity

In a command prompt this could look like:

c:\> mkdir c:\mylib\my\tools
c:\> cd /D c:\mylib

  1. create your java file(s) ie:

first file: c:\mylib\my\tools\
ie: provides static methods for use as an example


public class MyStaticTools { 
 public static int addValues(int a, int b) {
   return a+b;

 public static int subValues(int a, int b) {
   return a-b;

second file: c:\mylib\my\tools\
ie: provides class methods for use as an example


public final class MyClassTools { 
 public int multValues(int a, int b) {
   return a*b;

 public int powValue(int a) {
   return a*a;
  1. back in the command prompt (assuming you are already in the directory from step 1) type :
    assuming c:\processing is the directory where you’ve installed processing
  • The first command build .class files from you .java files into a bin directory
c:\mylib>c:\processing\java\bin\javac.exe -d bin my\tools\*
  • The second command build a structured .jar library from your .class files
c:\mylib>c:\processing\java\bin\jar.exe -cf mytools.jar -C bin my

As a final result you should see a mytools.jar file in the directory.

The content of the mytools.jar can be verified afterwards by command

c:\mylib>c:\processing\java\bin\jar.exe -tf mytools.jar

And should look like:


Afterwards drag and drop that file onto your PDE Window. This will create a folder named code in your sketch folder and loads the jar file for usage. If that all was successfully you can then use the provided functions in your sketch (minimalistic sketch example):



MyClassTools mytools = new MyClassTools();


The console output:


— mnse

EDIT:: fix typo

1 Like