Including shared pde files across projects

Thanks to the responders ! ! !

kfrajer suggests using the template folder and sketch.pde , useful info, but not exactly what I am after I created the template/java/sketch/pde and yes when in Processing you select File New you get a new file with the content of sketch.pde. Problem is if I change sketch.pde that will not ripple down to other older projects.

It seems to me that the suggestion by GoToLoop is what I am after a library that I can call from any project. If I can get ever get it working

I followed GoToLoop instructions to the best of my ability and created project/malcolm/malcolm.pde and project/malcolm/Palette.java from a cmd shell I then compiled it

Project/malcolm/malcolm.pde

import static malcolm.Palette.*;

background(BLUE);

strokeWeight(3.5);
stroke(RED);
fill(YELLOW);

ellipse(width>>1, height>>1, width>>1, height>>1);

Project/malcolm/Pallete.java

package malcolm;

public interface Palette {
  int
	WHITE = -1, 
	BLACK = 0xff000000, 
	RED = 0xffFF0000, 
	GREEN = 0xff008000, 
	BLUE = 0xff0000FF, 
	YELLOW = 0xffFFFF00, 
	MAGENTA = 0xffFF00FF;
}

myjavapath/javac Palette.java – which gave me a Palette.class

manifest.txt
Main-Class: malcolm

myjavapath/jar cfm malcolm.jar manifest.txt Palette.class – which created malcolm.jar

I got the information about the manifest.txt from youtube which told me how to run javac and jar If I leave the f option out to not use a manifest I get compile errors

I was not sure whether Main-Class: should be Malcolm or Palette tried both later errors are the same regardless

so anyway I now have a malcolm.jar

jar" tf ./malcolm.jar lists the contents of the file
META-INF/
META-INF/MANIFEST.MF
Palette.class

so anyway stuck the malcolm.jar into Processing\libraries and run Processing project\malcolm\malcolm.pde

i get a box with a circle - which is what malcolm.pde is supposed to do BUT

Processing says No library found for malcolm.Palette

Some more reading I came across Java - Packages it suggests that $CLASSPATH might be an issue , i didnt have a CLASSPATH so I created one

C:\Users\mnmmc\Documents\Processing\libraries>SET $CLASSPATH
$CLASSPATH = C:\Users\mnmmc\Documents\Processing\libraries

Unfortunately that didnt fix it - I guess that may not be needed in Processing

The preferences in Processing indicate a path to my Project directory and my library malcolm.jar is in the Project/libraries directory

So I can create jar file but I am still missing something, the naming is wrong or there is some path I haven’t set or I am just not holding my tounge between my teeth correctly.

1 Like