Forums Register Login

getting data from files in your CLASSPATH

+Pie Number of slices to send: Send
Hi gang
I'd like to retrieve information from files in the classpath of the running VM - e.g. .properties files. Is there a way of doing this without having to supply the physical location of the file on disk?
Thanks
Felix.
+Pie Number of slices to send: Send

You can get the information of your environment using System.getProperties(). The return type is java.util.Properties. I hope you can get information on the classpath also using this. Good Luck

Originally posted by Felix Ulrich:
Hi gang
I'd like to retrieve information from files in the classpath of the running VM - e.g. .properties files. Is there a way of doing this without having to supply the physical location of the file on disk?
Thanks
Felix.


+Pie Number of slices to send: Send
I'm afraid that's not much help - it only get System properties - e.g. user.dir, os.version, etc. I want to include a something.conf file in my classpath, and then load it from within my application, without using the File stuff in java.io.
Felix.
+Pie Number of slices to send: Send
THere's a get resourec or some such in either Class or ClassLoader (CL is my guess). I used it just the other day.
(Sorry this is deliberately vague but I'm tired and it's kinder than rtfm... )
Dave
+Pie Number of slices to send: Send
Thanks Dave - that's kind of what I've been trying:
InputStream is = ClassLoader.getSystemClassLoader().getSystemResourceAsStream("/db.conf");
I've also tried just getResourceAsStream(), but the input stream returned is null, and I know for sure that the file has stuff in it and that it is in the root of the classpath.
Felix =(
+Pie Number of slices to send: Send
I am having the same problem. Can anyone answer? :roll:
Thanks
Geoffrey
Whatever you say buddy! And I believe this tiny ad too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 701 times.
Similar Threads
Oh classpath, why do you hate me?
Help me with the calling of jasper reports through java code
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is
Taglib file outside WEB-INF
Exception when invoking standalone client
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:22:10.