importing custom "uncompressed" libraries (i.e., no JAR)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

importing custom "uncompressed" libraries (i.e., no JAR)

Gaetano Impoco
Dear all,
I developed a custom library for my own convenience that used to work in
ImageJ1.x. In my old IJ1 installation I used to add the library root directory
to the Java CLASSPATH (using a simple bash script).
In my brand new Fiji installation, I can import my library only if I archive all
.class files into a JAR file. I would like to use JARs only for deployment. Is
there any way to include the "uncompressed" (development version) library?

Thank you
Gaetano



_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: importing custom "uncompressed" libraries (i.e., no JAR)

Curtis Rueden
Hi Gaetano,

> In my brand new Fiji installation, I can import my library only if I
> archive all .class files into a JAR file.

IIUC, what you describe is still supposed to work.

Could you please provide a minimal, complete, verifiable example demonstrating the issue?


Regards,
Curtis

On Fri, Sep 12, 2014 at 6:05 AM, Gaetano Impoco <[hidden email]> wrote:
Dear all,
I developed a custom library for my own convenience that used to work in
ImageJ1.x. In my old IJ1 installation I used to add the library root directory
to the Java CLASSPATH (using a simple bash script).
In my brand new Fiji installation, I can import my library only if I archive all
.class files into a JAR file. I would like to use JARs only for deployment. Is
there any way to include the "uncompressed" (development version) library?

Thank you
Gaetano



_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel


_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: importing custom "uncompressed" libraries (i.e., no JAR)

Gaetano Impoco
Hi Curtis,

> Could you please provide a minimal, complete, verifiable example
> demonstrating the issue?

I created a small example that requires my library (please, download it at
http://www.impoco.it/files/gijLib.jar)

-------------

import ij.*;
import ij.process.*;
import ij.plugin.filter.*;
import java.awt.*;
import java.awt.geom.*;
import gijlib.binary.*;
import gijlib.geom.*;


public class Example_ implements PlugInFilter
{
  public int setup(String arg, ImagePlus imp)
  {
    return DOES_8G;
  }

  public void run(ImageProcessor ip)
  {
    ContourFollower cf = new ContourFollower(ip);
    if(cf.getNContours() != 1)
    {
      IJ.error("The input image should contain one and only one object!\nFound
"+cf.getNContours());
      return;
    }

    Point[] contour = cf.getContour(0);
    Point2D cHull[] = ConvexHull.grahamsScan(contour);

    Line2D  diam    = PolygonUtilities.computeDiameter(cHull);
    Line2D  odiam   = PolygonUtilities.computeOrthogonalDiameter(cHull, diam);
    OrientedRectangle obbox = PolygonUtilities.computeBoundingRect(diam, odiam);
  }

}

-------------

When I put gijLib.jar in the "jars" directory and compile this class using the
--javac option of the ij2 launcher, everything is ok. When I uncompress the JAR
file into the "jars" directory, the compiler cannot find the classes in the
library.

Moreover, if I try to run a plugin that includes a class in the same directory
(but not using packages) the compiler fails, as well. I avoid this problem
using the option --class-path $HOME/Fiji.app/jars/

Hope I gave enough information.

Thank you
Gaetano




Quoting Curtis Rueden <[hidden email]>:

> Hi Gaetano,
>
> > In my brand new Fiji installation, I can import my library only if I
> > archive all .class files into a JAR file.
>
> IIUC, what you describe is still supposed to work.
>
>
> http://imagej.net/Bug_reporting_best_practices
>
> Regards,
> Curtis
>
> On Fri, Sep 12, 2014 at 6:05 AM, Gaetano Impoco <[hidden email]> wrote:
>
> > Dear all,
> > I developed a custom library for my own convenience that used to work in
> > ImageJ1.x. In my old IJ1 installation I used to add the library root
> > directory
> > to the Java CLASSPATH (using a simple bash script).
> > In my brand new Fiji installation, I can import my library only if I
> > archive all
> > .class files into a JAR file. I would like to use JARs only for
> > deployment. Is
> > there any way to include the "uncompressed" (development version) library?
> >
> > Thank you
> > Gaetano
> >
> >
> >
> > _______________________________________________
> > ImageJ-devel mailing list
> > [hidden email]
> > http://imagej.net/mailman/listinfo/imagej-devel
> >
>



_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: importing custom "uncompressed" libraries (i.e., no JAR)

Curtis Rueden
Hi Gaetano,

I created a small example that requires my library

Thanks for the working example. I did some digging, and here is what I discovered:

- Vanilla ImageJ1 does not have a "jars/" folder, so unpacking your JAR there would not work in that scenario.

- Having an unpacked directory structure in "plugins/" _does_ work, though.

- The reason it doesn't work in ImageJ2 is because ImageJ2 recursively adds all subdirectories of all classpath directory elements to the effective classpath of the plugin class loader.

- I discussed with Johannes, and he decided not to support unpacked class files anymore [1].

Personally, I think there is a bug lurking there -- probably only the "plugins/" folder should have the recursive behavior described above -- but it is an edge case which we do not have time to fix right now. However, if you feel strongly about the issue, you are very welcome to submit a pull request addressing it!

Otherwise, I'd encourage you to switch to an IDE, and/or JAR-based development model. Let us know if you need further guidance with it. See also: http://imagej.net/Development

Regards,
Curtis


On Tue, Sep 16, 2014 at 4:54 AM, Gaetano Impoco <[hidden email]> wrote:
Hi Curtis,

> Could you please provide a minimal, complete, verifiable example
> demonstrating the issue?

I created a small example that requires my library (please, download it at
http://www.impoco.it/files/gijLib.jar)

-------------

import ij.*;
import ij.process.*;
import ij.plugin.filter.*;
import java.awt.*;
import java.awt.geom.*;
import gijlib.binary.*;
import gijlib.geom.*;


public class Example_ implements PlugInFilter
{
  public int setup(String arg, ImagePlus imp)
  {
    return DOES_8G;
  }

  public void run(ImageProcessor ip)
  {
    ContourFollower cf = new ContourFollower(ip);
    if(cf.getNContours() != 1)
    {
      IJ.error("The input image should contain one and only one object!\nFound
"+cf.getNContours());
      return;
    }

    Point[] contour = cf.getContour(0);
    Point2D cHull[] = ConvexHull.grahamsScan(contour);

    Line2D  diam    = PolygonUtilities.computeDiameter(cHull);
    Line2D  odiam   = PolygonUtilities.computeOrthogonalDiameter(cHull, diam);
    OrientedRectangle obbox = PolygonUtilities.computeBoundingRect(diam, odiam);
  }

}

-------------

When I put gijLib.jar in the "jars" directory and compile this class using the
--javac option of the ij2 launcher, everything is ok. When I uncompress the JAR
file into the "jars" directory, the compiler cannot find the classes in the
library.

Moreover, if I try to run a plugin that includes a class in the same directory
(but not using packages) the compiler fails, as well. I avoid this problem
using the option --class-path $HOME/Fiji.app/jars/

Hope I gave enough information.

Thank you
Gaetano




Quoting Curtis Rueden <[hidden email]>:

> Hi Gaetano,
>
> > In my brand new Fiji installation, I can import my library only if I
> > archive all .class files into a JAR file.
>
> IIUC, what you describe is still supposed to work.
>
>
> http://imagej.net/Bug_reporting_best_practices
>
> Regards,
> Curtis
>
> On Fri, Sep 12, 2014 at 6:05 AM, Gaetano Impoco <[hidden email]> wrote:
>
> > Dear all,
> > I developed a custom library for my own convenience that used to work in
> > ImageJ1.x. In my old IJ1 installation I used to add the library root
> > directory
> > to the Java CLASSPATH (using a simple bash script).
> > In my brand new Fiji installation, I can import my library only if I
> > archive all
> > .class files into a JAR file. I would like to use JARs only for
> > deployment. Is
> > there any way to include the "uncompressed" (development version) library?
> >
> > Thank you
> > Gaetano
> >
> >
> >
> > _______________________________________________
> > ImageJ-devel mailing list
> > [hidden email]
> > http://imagej.net/mailman/listinfo/imagej-devel
> >
>




_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel