Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

properties file in a jar

Thread view: 
frank - 24 Oct 2005 16:51 GMT
I was wondering is there any issues with having a common package have
it's property file also contained in it's jar file?  I'm having a
problem with it finding it when using that jar file in another
application that uses that common package.  It finds the classes in that
jar for compiling but not the property file for some reason.  Paths seem
to be correct from what I can see in the jar file.

Thanks,

Frank
frank - 24 Oct 2005 18:30 GMT
A follow-up question

I have a jar file that looks like this from contents stand point

c:> jar vtf csdsutility.jar
     0 Mon Oct 24 10:04:58 EDT 2005 META-INF/
    71 Mon Oct 24 10:04:58 EDT 2005 META-INF/MANIFEST.MF
  2633 Fri Oct 21 17:04:44 EDT 2005 csds/utility/JavaLogging.class
  1621 Fri Oct 21 17:04:42 EDT 2005 csds/utility/Logging.class
   868 Fri Oct 21 17:04:42 EDT 2005 csds/utility/LoggingMethod.class
  3204 Fri Oct 21 17:04:44 EDT 2005 csds/utility/TestLogging.class
  3004 Fri Oct 21 17:04:44 EDT 2005 csds/utility/Utility.class
  1142 Fri Oct 21 17:04:44 EDT 2005 csds/utility/WSLogging.class
    83 Tue Jul 26 21:59:26 EDT 2005 csds/utility/javalogging.properties

If I include the jar file above in some other program it should find the
javalogging.properties file correct?  It's failing in the common code
trying to find the properties file. I created a small driver that tests
the common code and it is fine it just does not work off the jar file.
Is there something weird about jar files and property files I don't know
about?  I thought when you included them on the java -classpath line it
was like that code was part of your application and the path followed also.

Thanks,

Frank

> I was wondering is there any issues with having a common package have
> it's property file also contained in it's jar file?  I'm having a
[quoted text clipped - 6 lines]
>
> Frank
Roedy Green - 25 Oct 2005 05:07 GMT
>If I include the jar file above in some other program it should find the
>javalogging.properties file correct?

see http://mindprod.com/jgloss/images.html 
for code samples how to use getResource and getResourceAsStream.

So yes, if they did the right code.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Roedy Green - 25 Oct 2005 05:03 GMT
>I was wondering is there any issues with having a common package have
>it's property file also contained in it's jar file?

Some problems, which are far from insurmountable, are:

1. making sure you name it properly with the package, case sensitive,
as the path name.

2. making sure you remember to include it in the jar, and that any
client of your class remember to include it in their jars. that
include your class. It won't be included automatically, even by
Genjar. See http://mindprod.com/jgloss/cramfull.html
for a way around that.

3. if you only sometimes need it, it will be downloaded anyway. If
only sometimes need it, put the resource in an aux jar with the
manifest in them main jar class-path referring to it.

4. If you change the properties frequently, you have to keep
rebuilding and resigning the jar. Further, all those changes screw up
any jar caching forcing the whole jar to be reloaded over and over.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.