This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Accessing Property-File outside of Jar?" Watch "Accessing Property-File outside of Jar?" New topic

Accessing Property-File outside of Jar?

Michael Veeck

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 ""

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
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.

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:
subject: Accessing Property-File outside of Jar?
jQuery in Action, 3rd edition