aspose file tools*
The moose likes Java in General and the fly likes Accessing Property-File outside of Jar? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Accessing Property-File outside of Jar?" Watch "Accessing Property-File outside of Jar?" New topic
Author

Accessing Property-File outside of Jar?

Michael Veeck
Greenhorn

Joined: Jan 28, 2005
Posts: 4
Hi there!
I have an application (packaged in a JAR-file) which needs to read in some properties from the file "db.properties"

Now I dont want to package the properties-file in the JAR-File because the user might want to change the props which would break the signature of the JAR.

But I cannot issue a call to getResource(...) on the main-class of the JAR (which only gets me a null-reference), all I can get is a reference to resources inside the JAR.

What am I doing wrong and what is the way to go here?

Thanx in advance
Veeck
Joseph Maddison
Ranch Hand

Joined: Nov 04, 2004
Posts: 53
I could be missing something here, but have you already considered using the load and store methods of the Properties class? It looks like all you need to do is open the file and call Properties.load() with the InputStream.

HTH,
jdmaddison
Vijay Vaddem
Ranch Hand

Joined: Feb 13, 2004
Posts: 243
Try this...



Store the jar file and properties file in the same folder and execute the jar file. It will get the current folder, read the properties file and
do the needful......
[ January 29, 2005: Message edited by: Vijay Vaddem ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing Property-File outside of Jar?