aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes problems with runme.jar referencing resources Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "problems with runme.jar referencing resources" Watch "problems with runme.jar referencing resources" New topic
Author

problems with runme.jar referencing resources

Andy Jung
Ranch Hand

Joined: Feb 07, 2010
Posts: 150
Hi,

when building package runme.jar I, have the problem that resources like userguide.html and icons cannot be referenced any more.
What's the trick doing this?

Kind regards,
Andy


SCJP, SCJD
Carlos Morillo
Ranch Hand

Joined: Jun 06, 2009
Posts: 221

Hi Andy,
Andy Jung wrote:when building package runme.jar I, have the problem that resources like userguide.html and icons cannot be referenced any more.


Are they supposed to be accessible from your application?
If they are I would think they should be in some directory with a relative pathname.

My application does not use any icons and I have a plain text userguide.txt.

I would think the userguide.html should be used by a web browser and located
in the docs directory with your choices.txt and javadoc directory.

Check in http://java.sun.com the jar documentation about how you build a more elaborate executable jar file.

HTH,

Carlos.


SCSA, OCA, SCJP 5.0, SCJD http://www.linkedin.com/in/carlosamorillo
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2246

Howdy, Andy!

Champion, if you are providing the help of your system as HTML files, then these files do not have to be accessible from the application. The help system just needs to be accessible from the application if it is within the application.

Now, you don't have to use icons, but if you still want to use them, how are you doing to retrieve the images? Try doing something like getClass().getResource(imagePath) to get the java.net.URL and build the ImageIcon.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Andy Jung
Ranch Hand

Joined: Feb 07, 2010
Posts: 150
Hi all,

the weird thing is, when running the application in my IDE, everything is fine.
When running it as an executable jar file it works but I cannot see any icons and my userguide.html (being displayed in a JDialog) anymore.

When analysing this with logs I got the following:
when running it in the IDE the current working directory is where the starting class is located.
when running it as part of a jar file the current working directory changes to the location the jar-file is placed.
So my relative paths don't match any more. So how can I address a jar-file when specifying a relative path?

Kidn regards,
Andy
Ralf Titgemeyer
Greenhorn

Joined: May 18, 2010
Posts: 9
Hi Andy,

you can also take a look in our company-internal forum, where you will find what you are looking for .... described by Juergen and me.
But it is exactly the way, Roberto described it..

So, take a look and good luck..

Ralf


SCJP 6.0
Andy Jung
Ranch Hand

Joined: Feb 07, 2010
Posts: 150
Hi Ralf,

thanks for the hint, I will have a look there. And if this doesn't work I will call you and bother you !

And good luck for tomorrow, buddy!

Andy
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4907
    
  10

Someone else had trouble accessing resources in the jar file: this thread can be found here.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Andy Jung
Ranch Hand

Joined: Feb 07, 2010
Posts: 150
... thanks guys, it works now!
It's exactly like Roberto and Ralf suggested .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problems with runme.jar referencing resources
 
Similar Threads
location of .properties file?
Bodgitt n Scarper - Assigning image to system tray icon
Uploading exam?
WA #1.....word association
Where are the java (standard) icons