ImageJ (IJ.jar) used as library for a Java app fails when run from a script

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ImageJ (IJ.jar) used as library for a Java app fails when run from a script

Robert Lockwood
I use ij.jar as a library to covert my camera data which is an array of
unsigned shorts representing a monochrome image which I get directly from
the camera using Java apps.  I use ImgeJ to save the data to file as 16 bit
unsigned PNG and as false color image after applying a LUT.

The small suite of apps are designed to start automatically when the LINUX
computer finishes booting.  No monitor or keyboard will be present.

In development when the computer starts I then log in and start Gnome to
get a window.  Running from Eclipse works.

Without Eclipse I can run my exported jar (using a script) from a terminal
and it works
If at boot I log in but don't start Gnome and run the script it fails and,
of course it fails if I set the script to be run automatically at the end
of the boot process.

The failure occurs when IJ tries to save the file:

  IJ.saveAs(imp, "PNG", imageFullPathName);

The error is: 'Unrecognized command: "PNG..."'

I hope that this failure is not due to the fact that the window system
(Gnome) has not been started.

I export my app as a "Runnable Jar File" and choose "Package require
libraries into generated jar"

My build path for Libraries points to ij.jar.

Have I missed something in my Eclipse project configuration for using IJ or
exporting the app?






One's first step in wisdom is to question everything - and one's last is to
come to terms with everything.

Georg C. Lichtenberg

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ (IJ.jar) used as library for a Java app fails when run from a script

Rasband, Wayne (NIH/NIMH) [E]
On Mar 17, 2015, at 2:03 PM, Robert Lockwood <[hidden email]> wrote:

>
> I use ij.jar as a library to covert my camera data which is an array of
> unsigned shorts representing a monochrome image which I get directly from
> the camera using Java apps.  I use ImgeJ to save the data to file as 16 bit
> unsigned PNG and as false color image after applying a LUT.
>
> The small suite of apps are designed to start automatically when the LINUX
> computer finishes booting.  No monitor or keyboard will be present.
>
> In development when the computer starts I then log in and start Gnome to
> get a window.  Running from Eclipse works.
>
> Without Eclipse I can run my exported jar (using a script) from a terminal
> and it works
> If at boot I log in but don't start Gnome and run the script it fails and,
> of course it fails if I set the script to be run automatically at the end
> of the boot process.
>
> The failure occurs when IJ tries to save the file:
>
>  IJ.saveAs(imp, "PNG", imageFullPathName);
>
> The error is: 'Unrecognized command: "PNG…”'

I do not know why the "PNG…” command (File>Save As>PNG) is missing but you can avoid using it by using the saveAsPng() method to save the image, for example

  new FileSaver(imp).saveAsPng(path);

There are similar methods in FileSaver for saving in other formats, such as saveAsTiff(), saveAsTiffStack(), saveAsZip(), saveAsJpeg() and saveAsRaw().

-wayne

> I hope that this failure is not due to the fact that the window system
> (Gnome) has not been started.
>
> I export my app as a "Runnable Jar File" and choose "Package require
> libraries into generated jar"
>
> My build path for Libraries points to ij.jar.
>
> Have I missed something in my Eclipse project configuration for using IJ or
> exporting the app?
>
>
>
>
>
>
> One's first step in wisdom is to question everything - and one's last is to
> come to terms with everything.
>
> Georg C. Lichtenberg
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ (IJ.jar) used as library for a Java app fails when run from a script

Robert Lockwood
In reply to this post by Robert Lockwood
Your solution worked.  I saved the latest build and will test it.

Thanks, Wayne, this was a major problem for the whole project and now I can
get back to finishing my code.

One's first step in wisdom is to question everything - and one's last is to
come to terms with everything.

Georg C. Lichtenberg

On Tue, Mar 17, 2015 at 1:47 PM, Rasband, Wayne (NIH/NIMH) [E] <
[hidden email]> wrote:

> Hi Robert,
>
> The latest ImageJ daily build (1.49q7) fixes a bug that could have caused
> the 'Unrecognized command: "PNG…"’ error you encountered. I have attached
> the daily build ( 1.49q7) or you can get it by using the Help>Update ImageJ
> command and selecting “daily build” from the drop down menu. Please test
> and let me know how it goes.
>
> Best regards,
>
> -wayne
>
> > On Mar 17, 2015, at 2:03 PM, Robert Lockwood <[hidden email]>
> wrote:
> >
> > I use ij.jar as a library to covert my camera data which is an array of
> > unsigned shorts representing a monochrome image which I get directly from
> > the camera using Java apps.  I use ImgeJ to save the data to file as 16
> bit
> > unsigned PNG and as false color image after applying a LUT.
> >
> > The small suite of apps are designed to start automatically when the
> LINUX
> > computer finishes booting.  No monitor or keyboard will be present.
> >
> > In development when the computer starts I then log in and start Gnome to
> > get a window.  Running from Eclipse works.
> >
> > Without Eclipse I can run my exported jar (using a script) from a
> terminal
> > and it works
> > If at boot I log in but don't start Gnome and run the script it fails
> and,
> > of course it fails if I set the script to be run automatically at the end
> > of the boot process.
> >
> > The failure occurs when IJ tries to save the file:
> >
> >  IJ.saveAs(imp, "PNG", imageFullPathName);
> >
> > The error is: 'Unrecognized command: "PNG..."'
> >
> > I hope that this failure is not due to the fact that the window system
> > (Gnome) has not been started.
> >
> > I export my app as a "Runnable Jar File" and choose "Package require
> > libraries into generated jar"
> >
> > My build path for Libraries points to ij.jar.
> >
> > Have I missed something in my Eclipse project configuration for using IJ
> or
> > exporting the app?
> >
> >
> >
> >
> >
> >
> > One's first step in wisdom is to question everything - and one's last is
> to
> > come to terms with everything.
> >
> > Georg C. Lichtenberg
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html