• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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: 24203
44
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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic