• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jar file probelm

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic