Real time processing

Sorry for the delay in answering. My recollection of the ImageJ classloader is hazy. It may be looking for something specific in the jars it found (see:, and I do remember sometimes struggling to get a jar to load. However, it may be easier to add your jar directly to the ImageJ.cfg file. The last line of that file contains the flags given to the JVM, including jars to load on the classpath (listed after the -cp flag). You should be able to add your jar to that list, and then it really should be on the main classpath, and the beanshell script should be able to find it. Let us know how it goes!

I believe that ImageJ has been loading the jar correctly - if I try and modify the jar file using a file browser, I am not allowed as it is open in Java Platform SE Binary. Adding the -cp flag to ImageJ.cfg hasn’t affected this.

From your link, the plugin examples all implement the class PlugIn, so I tried making a plugin which implements this. This has gotten me a little further - I can create an object in beanshell now, however using javap, I can only see the “run” method, not exec or getCentroid.

Does it help when you make
static double[] getCentroid(short[] pixels, int width, int height)

I thought that, and in the plugin I posted, it is public. It didn’t make a difference there though. Inspired though, I just tried changing this class to have a public static method and no package declaration, and this can be found on the classpath! I can call the method like so:

import Static_Image_Math;
pixels = new short[64*64];
double[] centre = Static_Image_Math.getCentroid(pixels, 64, 64);

Thanks for all your help! Hopefully this will now work and I won’t be back with more questions