tags:

views:

16

answers:

1

I'm developing a java web app on my local PC that uses a file on the deployment server. I have to do something like this to get it to work both locally during development and on the server when deployed. Is this standard practice? Or is there a way in Eclipse using linked folders and files to specify the file the same as it is referenced on the server?

InputStream in = null;
try {
   in = new FileInputStream("/EBWEB/www/homepages/path/to/file/STKCore.properties");
} catch (java.io.FileNotFoundException ex) {
            in = new FileInputStream("W:/internal/www/homepages/path/to/file/STKCore.properties");
}

W: is how I have the remote server mapped using Samba in Windows XP on my PC.

+1  A: 

You can put your properties file in your war and open it with a getResourceAsStream().

Colin Hebert
Note, the properties file needs to be in the classpath for this to work. An easy way to do this in Eclipse is to make sure it's in the src folder.
Taylor Leese
I was using ResourceBundle bundle = ResourceBundle.getBundle(file); but if I changed the properties file I needed to reboot the webserver to get the new properties to be read. I don't have the ability to reboot the production server. Will getResourceAsStream reload on the fly?
jeff