• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unable to read config file outside src folder

 
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have kept web service URLs in a Config file.so that my application can read the un commented URL present in config file and proceed.But this config file is inside my SRC folder.Now i want this to be dynamic so that I do not have to again create the war file once i change the URL in config file. What i want is if i am changing the config file my application should just pick it from config file outside war an there is no need of recreating the war file.How to accomplish this.
thanks.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Monica. Shiralkar wrote:iWhat i want is if i am changing the config file my application should just pick it from config file outside war an there is no need of recreating the war file.How to accomplish this.


Have a look at the Properties (java.util.Properties) class. However, I don't think your problems end there. How "current" does your config need to be? If immediate, then you're likely to need some code to ensure that it is, and that's likely to involve synchronized (and possibly threaded) updates. If not, then you might want to look at a TimerTask (or something similar) that updates your config on a regular basis.

Tons of possible solutions; not enough information...

Winston
 
Monica Shiralkar
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks.
actually what i need is. Suppose my url changes. So I want to just change in the config file without the need to redeploy the war. Now currently my config file is inside SRC folder so if the url is to be changed its inside src.how do i change it.suppose cofig file is say in D: I can just change the URL in this file and no need to redeploy war.but if i give path of outside src e.g D: i am not able to read the config file.
 
Ranch Hand
Posts: 91
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Currently how are you reading the config file(when it is in the src folder)?

If you will have to separate the config file outside your war, then you may have to know the exact location of the config file and load using FileInputStream.
If not, this file's location should be in your class path and you should use
getResourceAsStream to load this file.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic