Troubleshooting an Issue with 3rd Party Library Integration

Hello all,

I am working on a project that uses the ImageJ library for image analysis and I have run into a problem that I don’t understand. I have downloaded the ImageJ jar file, added it to my project, and created a test file which uses the ImageJ classes and functions as a proof of concept for my larger project.

That test was done in without setup() or draw() and was just run through once when the run button was pressed.

When I tried to integrate the code into my larger project (which has setup() and draw() functions) it showed that some of the same class constructors that I used weren’t recognized. Below is a code snippet from the proof of concept.

import ij.*;
import ij.process.*;
import ij.plugin.filter.ParticleAnalyzer;
import ij.measure.ResultsTable;
import ij.text.TextWindow;
import ij.WindowManager;

//init ImagePlus
ImagePlus imp = new Opener().openImage(this.imagePath);
println("Image loaded...");

/////////////
// There are image analysis functions here
/////////////

double minSize = 0;
double maxSize = 999999;
int options = ParticleAnalyzer.SHOW_RESULTS;
int measurements = Measurements.AREA;
ResultsTable rt = new ResultsTable();
ParticleAnalyzer pa = new ParticleAnalyzer(measurements, options, rt, minSize, maxSize);
pa.analyze(imp);
println("Particles Analyzed...");

/////////////
// I do stuff with the ResultsTable and the particle data here.
/////////////

When I try to integrate this into my larger project everything seems to be recognized by the compiler EXCEPT these two lines:

ResultsTable rt = new ResultsTable();
ParticleAnalyzer pa = new ParticleAnalyzer(measurements, options, rt, minSize, maxSize);

These are the errors shown in Processing:
The constructor “ResultsTable()” does not exist
The constructor “filter.ParticleAnalyzer(int, int, ResultsTable, double, double)” does not exist

I did double check in the ImageJ API to make sure these were the correct constructors, so I am at a loss for what the issue is here.

I would really appreciate any advice on this.

Thank you,
Grayson

One guess – did you double-check that the ij.jar had actually been added separately to your larger project? Drag and drop install of jars is per-sketch.