permaculture playing cards*
The moose likes Tomcat and the fly likes Reading property file in a jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Reading property file in a jar file" Watch "Reading property file in a jar file" New topic
Author

Reading property file in a jar file

Eileen Chong
Greenhorn

Joined: Jul 10, 2003
Posts: 5
I have a jar file going to be deployed in the web application web-inf\lib directory. However, one of the method that reading configuration value from a property file distributed together in the jar file fail to read the property file. It was pointing to the windows\system32 direcotry if i access it via jsp but it works fine if i run it standard-alone. Any way to work around this as this jar file should be self-provide classes, no configuration value should be passed in as argument.
I am using tomcat 4.1.2. Will it have the same problem if i deploy in other web container such as Webshpere? Any way to make it works across different web containers? Thanks in advance for any reply.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

That's probably because you are trying to load the properties file from the file system?

Re-write that code to use a classloader.getResourceAsStream() method.
mshravan kumar
Greenhorn

Joined: Jan 27, 2009
Posts: 2
Mike Curwen wrote:That's probably because you are trying to load the properties file from the file system?

Re-write that code to use a classloader.getResourceAsStream() method.


Thanks Mike. I got around this problem and your solution helped me.

Shravan Kumar.M
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading property file in a jar file