Skip to main content

executable jar

8 replies [Last post]
randav
Offline
Joined: 2010-08-10

Hello
I have a program that reads dicom images using jai imagio
when I run it from eclipse there is no problem and it works fine
however when I pack it as an executable jar it doesnt show the images
the path is given by jfilechooser and I checked it is reading all other files
the program stops fter the line

java.util.Iterator itr = ImageIO.getImageReadersByFormatName("DICOM");

this is the code complete
the joptionpane lines are for knowing where is the problem

ImagePlus ip = new ImagePlus(f.getAbsolutePath());
ImageProcessor rr = ip.getProcessor();
short[] pixels = (short[])rr.getPixels();
for (int i=0; i0");
java.util.Iterator itr = ImageIO.getImageReadersByFormatName("DICOM");
JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>1");
ImageReader reader = (ImageReader) itr.next();
JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>2");

org.dcm4che2.imageio.plugins.dcm.DicomImageReadParam param = (org.dcm4che2.imageio.plugins.dcm.DicomImageReadParam) reader.getDefaultReadParam();
JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>3");
ImageInputStream iis = ImageIO.createImageInputStream(f.getAbsoluteFile());
JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>4");
JOptionPane.showMessageDialog(null,f.getAbsolutePath());
JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>5");
reader.setInput(iis,false);
JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>6");
BufferedImage bimg = reader.read(0, param);
JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>7");
//BufferedImage bimg = ImageIO.read(f);
this.images.add(bimg);
JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>8");
GlobalDataStore.imgMarkCount.add(new Integer(0));
JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>9");
GlobalDataStore.files.add(f.getAbsoluteFile());
JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>10");
GlobalDataStore.markedPoints.add(new ArrayList());
GlobalDataStore.pix.add(pixels);
} catch (IOException e) {
JOptionPane.showMessageDialog(null,e.toString());
}
}

please can anyone help with how to run the executable jar that it will work
????

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Harald Kuhr

On 11. aug. 2010, at 10.41, jai-imageio@javadesktop.org wrote:

> I am not distributing this
> all I need is to give it to my professor as a part of my final project in B.sc

If your project relies on it, why not just ask your professor to intall JAI ImageIO? Provide links and install guidelines. As a bonus, it does not break any licenses. :-)

--
Harald K

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Harald Kuhr

I assume the line that fails is the one containing itr.next(). There is no DICOM reader available. Sounds like a classpath problem.

Do you have a classpath entry in the manifest of your Jar? And is your DICOM library available at the path specified?

If you re-packaged the DICOM library into your Jar, did you remeber to keep the META-INF/services/javax.imageio.spi.ImageReaderSpi entries?

--
Harald K

Sent from my iPad

On 10. aug. 2010, at 22.17, jai-imageio@javadesktop.org wrote:

> Hello
> I have a program that reads dicom images using jai imagio
> when I run it from eclipse there is no problem and it works fine
> however when I pack it as an executable jar it doesnt show the images
> the path is given by jfilechooser and I checked it is reading all other files
> the program stops fter the line
>
>
> java.util.Iterator itr = ImageIO.getImageReadersByFormatName("DICOM");
>
>
> this is the code complete
> the joptionpane lines are for knowing where is the problem
>
>
> ImagePlus ip = new ImagePlus(f.getAbsolutePath());
> ImageProcessor rr = ip.getProcessor();
> short[] pixels = (short[])rr.getPixels();
> for (int i=0; i
> pixels[i] = (short)(pixels[i]-32768);
> JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>0");
> java.util.Iterator itr = ImageIO.getImageReadersByFormatName("DICOM");
> JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>1");
> ImageReader reader = (ImageReader) itr.next();
> JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>2");
>
> org.dcm4che2.imageio.plugins.dcm.DicomImageReadParam param = (org.dcm4che2.imageio.plugins.dcm.DicomImageReadParam) reader.getDefaultReadParam();
> JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>3");
> ImageInputStream iis = ImageIO.createImageInputStream(f.getAbsoluteFile());
> JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>4");
> JOptionPane.showMessageDialog(null,f.getAbsolutePath());
> JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>5");
> reader.setInput(iis,false);
> JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>6");
> BufferedImage bimg = reader.read(0, param);
> JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>7");
> //BufferedImage bimg = ImageIO.read(f);
> this.images.add(bimg);
> JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>8");
> GlobalDataStore.imgMarkCount.add(new Integer(0));
> JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>9");
> GlobalDataStore.files.add(f.getAbsoluteFile());
> JOptionPane.showMessageDialog(null,f.getAbsolutePath()+"------>10");
> GlobalDataStore.markedPoints.add(new ArrayList());
> GlobalDataStore.pix.add(pixels);
> } catch (IOException e) {
> JOptionPane.showMessageDialog(null,e.toString());
> }
> }
>
>
> please can anyone help with how to run the executable jar that it will work
> ????
> [Message sent by forum member 'randav']
>
> http://forums.java.net/jive/thread.jspa?messageID=479804
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

randav
Offline
Joined: 2010-08-10

first the line that fails is the line before that
getreadersbyformat...
I know this because I don't get the msg box with 1
second all I did is clicked on the project ->export ->excutable jar
do I" need to do this somehow different
???
10x

marcojacob
Offline
Joined: 2006-07-10

Maybe the executable jar is missing the ext libraries of the JRE
containing jai_imageio.jar with the codec for DICOM. Which JRE
do you use to execute the JAR file? Is it the same JRE with jai_imageio
installed?

You can use a ZIP program to analyse the JAR file and see what
is in there.

randav
Offline
Joined: 2010-08-10

cant I pack the jar file with the jai imageio jar so that I can deliver the program to anyone I want
????

marcojacob
Offline
Joined: 2006-07-10

There is no chance to pack the dependent jar files in your jar file.
You will get information about this topic search google for
"pack lib into jar".

You can only unpack the dependent jar files and put the packages
in you jar file. I'm not quite sure about the license issues. Maybe
you are not allowed to repack the classes in a different jar file
for distribution. But it should work.

Be aware that you only get the pure Java classfiles not the native
codecs. I don't know if the DICOM codec is also available in
pure Java code.

Another approach might be to use Launch4J to make an
executabel with Launch4j: http://launch4j.sourceforge.net/

I didn't try it but it sounds good to me.

randav
Offline
Joined: 2010-08-10

tnx a lot
with the link you gave me I can create an executable that will work
????
I am not distributing this
all I need is to give it to my professor as a part of my final project in B.sc
can you give me a quick instruction on how to repack the imageIO jar into mine
(unpack aand put the packages)
???

marcojacob
Offline
Joined: 2006-07-10

There is an open source project called "One-Jar" and also
an eclipse plugin. Searching "pack lib into jar" will help.
Here are the direct links:

http://one-jar.sourceforge.net/
http://fjep.sourceforge.net/