Errors when compiling some "imagej-tutorials" examples

Dear all,

I get errors when I try to compile with the sample plugins copied to: imagej/src/main/java/net/imagej for some plugin samples.

./imagej/src/main/java/net/imagej/imagej-tutorials/commands-with-preview/src/main/java/CommandWithPreview.java:[9,10] package ij does not exist
./imagej/src/main/java/net/imagej/imagej-tutorials/commands-with-preview/src/main/java/CommandWithPreview.java:[28,17] cannot find symbol
  symbol:   class ImagePlus
  location: class CommandWithPreview
./imagej/src/main/java/net/imagej/imagej-tutorials/execute-commands/src/main/java/ExecuteCommands.java:[22,39] package org.scijava.plugins.commands.io does not exist
./imagej/src/main/java/net/imagej/imagej-tutorials/commands-with-preview/src/main/java/PreviewCheckbox.java:[9,10] package ij does not exist
./imagej/src/main/java/net/imagej/imagej-tutorials/commands-with-preview/src/main/java/PreviewCheckbox.java:[32,17] cannot find symbol
  symbol:   class ImagePlus
  location: class PreviewCheckbox
./imagej/src/main/java/net/imagej/imagej-tutorials/add-two-datasets/src/main/java/AddTwoDatasets.java:[18,27] package net.imglib2.ops.img does not exist
./imagej/src/main/java/net/imagej/imagej-tutorials/add-two-datasets/src/main/java/AddTwoDatasets.java:[19,33] package net.imglib2.ops.operation does not exist
./imagej/src/main/java/net/imagej/imagej-tutorials/add-two-datasets/src/main/java/AddTwoDatasets.java:[20,44] package net.imglib2.ops.operation.img.binary does not exist
./imagej/src/main/java/net/imagej/imagej-tutorials/add-two-datasets/src/main/java/AddTwoDatasets.java:[21,45] package net.imglib2.ops.operation.real.binary does not exist
./imagej/src/main/java/net/imagej/imagej-tutorials/simple-commands/src/main/java/ComputeStats.java:[10,26] package net.imagej.measure does not exist
./imagej/src/main/java/net/imagej/imagej-tutorials/simple-commands/src/main/java/ComputeStats.java:[28,17] cannot find symbol
  symbol:   class StatisticsService
  location: class ComputeStats
./imagej/src/main/java/net/imagej/imagej-tutorials/call-modern-from-legacy/src/main/java/DisplayATable.java:[9,10] package ij does not exist
./imagej/src/main/java/net/imagej/imagej-tutorials/call-modern-from-legacy/src/main/java/DisplayATable.java:[10,14] package ij.gui does not exist
./imagej/src/main/java/net/imagej/imagej-tutorials/call-modern-from-legacy/src/main/java/DisplayATable.java:[11,17] package ij.plugin does not exist
./imagej/src/main/java/net/imagej/imagej-tutorials/call-modern-from-legacy/src/main/java/DisplayATable.java:[20,39] cannot find symbol

If I delete the examples with errors the rest of the plugins compile successfully.

Is it a problem of my installation or is it a problem of the examples sources?

Thank you very much for your help.

Sincerely

Karl-Heinz

Hello again,

I could fix most errors in the source code by searching for the missing dependencies. Netbeans usually finds more than one solution for the missing dependency (see screenshot).

Is there any rule to decide which dependency should be selected?

In my first attempt I downloaded the files from Github as a zip-archive. I could not get all tutorial plugins to work, however. Finally, for pure curiosity and to practice Git, I pulled the imagej-tutorials via the Netbeans > Team > Git > Clone command and could easily compile without errors (probably because I already had all dependencies in my local .m2 maven repository now).

So please consider this problem as solved.

Sincerely

Karl-Heinz

Dear Karl-Heinz,

is there a reason why you have copied the tutorials in the first place? You can just download the current master from GitHub and open the project.

This, however, doesn’t seem to pull in any dependencies of dependencies for tutorials / modules immediately. Just let Netbeans do its magic and download the maven repository indices (which took some time for me). After some time, you can right click on a project an Reload POM, which solved the problem of missing dependencies for me.

Is there any rule to decide which dependency should be selected?

The net.imagej:ij dependency is a mavenized version of ImageJ1 and contains ij.* packages like the one requested in your example.

All the best,
Stefan

1 Like

Dear Stefan,

thank you for your help.

I think I did not wait long enough. I realized in later experiments, what Netbeans was doing something in the background which I did not see earlier.

It appears to me that one has to know beforehand which depencency fullfills the requirements of a plugin, like you know from experience that net.imagej:ij is the right selection in my example.

When writing my own code this should be no problem, but with someone else’s code I have no clue how to make the right decision if Netbeans offers more than one option to solve missing dependencies. It looks like it might be a trial and error approach during my learning phase.

Thank you very much.

Sincerely

Karl-Heinz

You can search by class for Maven artifacts. For example, search for ij.plugin.PlugIn. There is also a “Find Jar For Class” helper script in Fiji which does a similar thing for JAR files currently on ImageJ’s classpath.

2 Likes

There is also a “Find Jar For Class” helper script in Fiji which does a similar thing for JAR files currently on ImageJ’s classpath.

That is so useful and I did not know about it! :frowning: Thanks @ctrueden!

1 Like