-
1. Re: Reading a configuration file
shakirpm4u Oct 29, 2013 1:28 AM (in response to aecordoba)Ideally, You should be able to put anywhere in the server. Only thing is you have to configure the proper location on your project.
Properties prop = new Properties();
InputStream in = getClass().getResourceAsStream("foo.properties");
prop.load(in);
in.close();Or if you plan to read from Classpath, Put it in WEB-INFclasses folder. Thats the right place. I dont think bin is correct location.
Thanks
-
2. Re: Reading a configuration file
wdfink Oct 29, 2013 3:59 AM (in response to aecordoba)Reading properties from a file is not a portable way and violate the spec (you should not use java.io.*).
You might use the WEB-INF/classes folder as shakirpm4u describe other option in AS7 is to set it as system-property within the configuration.
-
3. Re: Reading a configuration file
aecordoba Oct 29, 2013 7:58 AM (in response to shakirpm4u)Thank you, Shakir.
Thank you, Wolf-Dieter.
-
4. Re: Reading a configuration file
ryanaguilar Oct 29, 2013 9:47 PM (in response to aecordoba)Nice very helpful
-
5. Re: Reading a configuration file
celle2006 Oct 31, 2013 5:56 AM (in response to aecordoba)Hi Adrian,
i put my properties files in a custom module. So i have to reference it in the MANTIFEST.MF file with the Dependencies attribute. When i want to read the file i have to load it like this:
Properties props = new Properties();
props.load(this.getClass().getClassLoader().getResourceAsStream("foo.properties"));
The advantage to put properties file in modules section. You do not have to change the properties everytime you deploy to your productiv system, if you have differences between developing and productiv systems.
Kind regards
Marcel
-
6. Re: Reading a configuration file
l33thaxor May 22, 2018 11:52 AM (in response to wdfink)Using java.io.* gave me huge performance issues. I am hoping to find a solution where I don't have performance issues