Accessing App resources After packaging in a Jar file

I have a small application that contains few packages and a folder that holds configuration files (xml files), which are accessed by my classes at runtime. The application does not work when I package it in a jar file. My classes cannot find configuration files. I unpacked (unzipped) the jar file and I can see that the folder and configuration files are there. I used to refer to the configuration files using relative path e.g. 搈yfolder/config.xml?br>I tried Google, and I concluded that it is recommended to use URL instead of relative path, but I do not know how to do that?

I would like also to mention that I am using 3rd party classes from Apache, which uses the configuration files as a string. I checked their documentation, they do not have a constructor that takes a URL, and I do not know what to do to overcome this problem.

Any help, a like to a book, or URL will be very appreciated

Best Regards

Thabet

[949 byte] By [Tha_noita] at [2007-11-27 7:17:03]
# 1
Try this:URL url = this.getClass().getResource("/myfolder/config.xml");If the resource is not found, url will be null.Another Class method, getResourceAsStream, is also useful.
Hippolytea at 2007-7-12 19:05:44 > top of Java-index,Java Essentials,Java Programming...