• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problems with runme.jar referencing resources

 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Carlos Morillo
Ranch Hand
Posts: 221
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10666
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone else had trouble accessing resources in the jar file: this thread can be found here.
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... thanks guys, it works now!
It's exactly like Roberto and Ralf suggested .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic