• Post Reply Bookmark Topic Watch Topic
  • New Topic

jar file probelm

 
Manoj Tare
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I have problem with executing jar file .

I have create swing application which is bundled in jar file.
(execuable jar file).
( jar file contains class file , images and manifest file )
For ex. :

My class name ShowImg which display images . (images from images folder)
Toolkit kit = comp.getToolkit();
Image img = kit.createImage("./images/nature.jpg");
using following command i have created jar file.
jar -cvfm test.jar man.mf ShowImg.class images\nature.jpg


When i run jar file in same directory where images folder exists it
works fine. But when i copy test.jar file some where else it doesn't
work. It displays only frame not image.

Give some tips ........
thx in advance
Manoj
 
Manoj Tare
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI ,
I have used following code for display imageIcon on Jbutton.
It throws NullPointerException when i try to run application through
jar file.
JButton butt = new JButton( );
URL url = getClass().getClassLoader().getResource("images/ash.jpg");

ImageIcon imgSearch = new ImageIcon(url);
butt.setIcon(imgSearch);
Excetion :

Uncaught error fetching image:
java.lang.NullPointerException
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you need to make the path to the file an absolute path, since the class is in the default package. I'm not 100% sure about this but it's worth a try. Add a "/" to the beginning of the image file path.
 
Erwin Bredford
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well check the filenames of the images the names of the images are case-sensitive in a jar file .so make sure the file names of the images are correct
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!