Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Mar 17, 2015; 8:18pm
URL: http://imagej.273.s1.nabble.com/ImageJ-IJ-jar-used-as-library-for-a-Java-app-fails-when-run-from-a-script-tp5012020p5012021.html
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