Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Load a Properties File from JAR File at runtime

Status
Not open for further replies.

hallian92

Programmer
Jul 30, 2002
8
US
HI,
How can we load a properties file from a jar file at runtime. Have a Properties file that's in a jar file when the application starts wants to read the values in the properties file. How can we do this. Any help is appreciated.
Thanks
 
To load resources from a jar file, use the getResource method of the Class class. if u call ur class as myclass, then

URL url = myclass.class.getResource("file.properties");

then pass this url to ur FileInputStream or whatever to open it.

luv
Karthik.
LOL A ship is safe in the harbour, but that's not what it is meant for!!! LOL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top