Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

File reading in a .war file?

Thread view: 
ddog - 27 Jul 2007 16:38 GMT
Hi,
I've been tasked with writing code that simply reads values from a
properties file. The executing code will reside in a .war file and be
run on JBoss. I'm not able to test the code under JBoss at this time.
The code below works properly when tested via a main() method but I've
read there may be issues running it in a .war file. Can someone tell
me if this is the preferred method to do this under my circumstances?
I don't want to turn this in and have it blow up when it's deployedm :
(

 FileInputStream fp =new FileInputStream(PROPERTIES_FILE);
 Properties props =System.getProperties();
 props.load(fp);

Thanks in advance!
Daniel Pitts - 27 Jul 2007 20:54 GMT
> Hi,
> I've been tasked with writing code that simply reads values from a
[quoted text clipped - 11 lines]
>
> Thanks in advance!

You are better off putting the file into the class path, and use
InputStream fp
MyClass.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE);

Also, I would think its a bad idea to load your properties file in
with the System properties file, unless you REALLY want to do that.

Alternatively, if its just a few properties, and they should be in the
system properties, you might consider simply modifying the script you
use to start JBoss and add -Dprop.name=value for the properties you
want to set.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.