Skip to main content

where to put properties file

2 replies [Last post]
lussej
Offline
Joined: 2009-10-05

In the prototype system that I am setting up, I need to implement several web services, with different describing names, but otherwise the same java code. For performance reasons I don't want to have the full development environment on all the connected computers, but only install what is needed on some of them, and execute the services from war and jar files (if possible). The service has also a local GUI client.
For storing the service-dependent (= personal, org.unit, etc.) parameters, I thought that I could use property files, so that I wouldn't need to hard-code all the parameters, image paths, etc. But here I run into a problem: in which folder shall I put the properties file, so that it's accessible both to the web service and the GUI? How with other files that the program needs, like images, in which directory does java look for for them? I have sometimes used resourceBundles, which I think is quite similar to properties, but that was either with Tomcat or plain Java programs and many years ago, so don't remember where I put them. I use mostly Windows (Vista or XP), but I wish that this service and GUI should be portable to Linux also.
Tried to put it in the source root from which Netbeans copied it automatically to class root, this does at least not work.

Jan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
houston_dragon
Offline
Joined: 2009-11-19

Under glassfish_home\domains\domain1\applications\j2ee-modules\
Create a folder called "whatever" name
Put you properties file there

In JSP, when you want to access this file, use this code

String propertiesfile = new File(application.getRealPath("/")).getParent() +
File.separator + "whatever" +
File.separator + "your_property_file.properties";

Note: the j2ee-module folder will be created only after you deployed your application
Note: I did this in glassfish version 2

lussej
Offline
Joined: 2009-10-05

I managed to find out this partly in the Netbeans environment, for the Glassfish services the files seem to be in the ...\doman_1 folder, and for java executables soemwhere else (don't remember as I don't now have the here). Both were such folders, from which the search tools in Windows Vista did not find them. But how if I run the codes without Netbeans IDE?