When to use properties file

On navigating into any web application there wil be some .proeprties file (build.proeprties, applicationResources.properties etc..) and some .xml files(web.xml, struts-config.xml). Why .properties file why not all in XML ??

The question should be: why XML and why not a properties file? XML is lots of overhead for simple tasks.

Similar Messages

  • How to use properties file

    Hi,
    I want to use properties file in my application. I have kept properties file inside a directory called properties which is inside myProject(which is the parent directory of my project) i.e "myProject/properties".
    My java file where i want to call this properties file is inside the myProject/WEB-INF/src/java.
    How can i call the properties file from myProject/WEB-INF/src/java/PropertyReader.java
    I wrote java program in myProject/WEB-INF/src/java/PropertyReader.java like:::::
    ResourceBundle resBun = ResourceBundle.getBundle("Test", Locale.getDefault()); // Test.properties is inside myProject/properties
    resBun..getString("name");
    After running the program i am getting the following errors:::::
    Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name Test, locale en_US
    at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:836)
    at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:805)
    at java.util.ResourceBundle.getBundle(ResourceBundle.java:576)
    at PropertiesReader.main(PropertiesReader.java:4)
    What is the issue? How to use properties file?
    Waiting for reply.
    Thanks

    Still getting same exception. As you explained i tried like the below:::
    1. I am using ant as build tool.
    2. My properties file is for database configuration
    My properties file is::
    database.properties (inside myProject/properties)
    JDBCDriver=org.gjt.mm.mysql.Driver
    JDBCConnectionURL=jdbc:mysql://pmdbmysql:3306/bandwidthshaper?user=admin&password=admin
    My java package structure is
    WEB-INF/src/java
    WEB-INF/src/classes
    For build WEB-INF is the base directory and build.xml is inside the src directory
    In my build.xml i wrote the following lines for compilation::
              <target name="compile" >
                   <javac srcdir="src" destdir="src/classes" debug="true" debuglevel="lines,vars,source">
                        <classpath refid="class.path"/>
                   </javac>
    <copy todir = "src/classes" >
    <fileset dir = "../properties" />
    </copy>
                   <jar jarfile="lib/${project.jar.file}" basedir="src/classes"/>
              </target>
    I am copying properties file to the classes directory.
    Now in java file which is inside /WEB-INF/src/java, I wrote::
    try {
    Properties programProps = new Properties();
    InputStream is = getClass().getResourceAsStream("/database.properties");
    if(is == null)
    throw new IllegalStateException("Properties file missing ");
    programProps.load(is);
    System.out.println("driver name::::::: "+programProps.getProperty("JDBCDriver"));
    is.close();
    } catch(Exception e) {
    e.printStackTrace();
    After compilation in my classes directory i am getting database.properties file and my java file with package.
    At the time of running i am getting "java.lang.IllegalStateException: Properties file missing"
    Now tell me where is the fault. Why again i am getting exception.
    Thanks

  • How to use .properties files in Webdynpro Java code?

    Hi all,
      I want to use a logon.properties file when I initial a JCO connection pool in my webdynpro DC (JCO.addClientPool()),but  I found when I deployed this DC to the server, it always giv e me an FileNotFoundException. So I donot know how to deploy a .properties file to the server and how to access this file in my Java code?
    Thans and Best regards
    Deyang

    Hi,
    1) put .properties file to your packege under src\packages folder (src\packages\com\sdn\properties\jco.properties)
    2) load property:
         final InputStream is = getClass().getClassLoader().getResourceAsStream("com/sdn/properties/jco.properties");
         final Properties properties = new Properties();
         try
              properties.load(is);
         catch(Exception e)
              wdComponentAPI.getMessageManager().reportException(new WDNonFatalException(e), false);
    Regatds Maxim R.

  • Use properties file in Struts framework

    I develop a websit with struts, web ap is tomcat5.0, and I have a conf.properties file
    this file is different from ApplicationResource.properties, conf.properties in the /MySite/conf/ directory, not in src directory
    When I Use the conf.properties file in a Common Java Class that not extends any super class
    it will occur a FileNotFoundException exception
    How to make it
    public class Environment
         private static Properties prop = new Properties();
         private static FileInputStream in = null;
         public static String getVariable(String key)
              try
                   in = new FileInputStream(new File("\\conf\\config.properties"));
                   prop.load(in);
                   return prop.getProperty(key, null);
              catch (Exception e)
                   e.printStackTrace();
                   return null;
              finally
                   try
                        in.close();     
                   catch(Exception e)
                        e.printStackTrace();
         }

    Your class cannot find the file in the location tht u have given. The path (\\conf\\config.properties) is relative to the location where your source (Environment class) is kept.
    Try to hard code the path & see if your source can find the prop file ...

  • Using .properties file in web dynpro

    Hi,
    I am having a requirement. I have to create a .properties file and I have to use it in my web dynpro application. How can I do that? Any help...
    Thanks & Regards,
    Raj

    Hi,
    Go to the navigator view...select src\Components\<ComponentName> and create create a .properties file.
    You can read the  configuration file in your webdynpro app as follows
    IWDConfiguration configuration =
          WDConfiguration.getConfigurationByName(
            wdComponentAPI.getDeployableObjectPart(),
            "<<>>");
    http://help.sap.com/saphelp_nw04/helpdata/en/b8/aa343e32ff1033e10000000a114084/frameset.htm
    Regards, Anilkumar
    Message was edited by:
            Anilkumar Vippagunta

  • How use properties file

    Hi i read about properties file in java .. i didn't get much more..
    how can we use this in program.. what is the benefit..
    anyone know any examples in site.please let me know about that

    int count=getGoogleSearchCount();
    public int getGoogleSearchCount(){
    search keyword="http://www.google.co.ke/search?hl=en&q=java+properties+class&btnG=Google+Search";
    // missing code
    return count;
    System.out.println(count);i ran the above code snipplet and guess the output?
    291,000 results.
    DONT BE LAZY.

  • Use properties file out of EAR

    HI All,
    Generally we create an EAR file with all the property files embedded in it. Here the problem is as and when we change the property files we need to build a new ear file and redeploy to J2EE stack.
    Is there any way that this properties file is out of EAR application and changes done to the property file reflects in EAR? So that, no need to redeploy the application again and again. Means dynamic reflecting of property changes to already deployed EAR application. How it can be done?
    Actually this is our client requirement also...
    Hope am clear.
    Regards,
    Satish.

    Hi,
    There are ways to achieve this.
    I guess you can try following.
    You can define properties file in another project (like java project) and then include that project as a reference in your EAR application.
    Ashutosh

  • How to read multiple files at multiple locations using properties file

    hi all ,
    in my code i take configuration input from a properties file ,it was really easy but what if there are multiple files ? how can i take configuration input (file path etc) from properties file in that case ? any suggestion ?

    thanks :) ..i am doing like this :
    String fName[]=new String[10];
              String choice[]=new String[10];
              String Delim[]=new String[10];
              ResourceBundle a = ResourceBundle.getBundle("input");
              String n=a.getString("NOF");
              try
                   for(int i=0;i<Integer.parseInt(n);i++)
                        fName=a.getString("PATH"+(i+1));
                        choice[i]=a.getString("HEADER"+(i+1));
                        Delim[i]=a.getString("DELIMITER"+(i+1));
                        putData(fName[i],choice[i],Delim[i]);//to put data in database
              catch (NumberFormatException e)
                   System.out.println("Number of files are invalid");
    hope this method would be fine ....again thanks for the advice :) :)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • CS5 crashes when previewing using temporary file

    Hello everyone!
    I've started having an issue with CS5 crashing anytime I try to preview a doc with out saving it first.
    I've had the "Preview using temporary file" option checked for more than a year and never had an issue.
    Any ideas?
    Thanks So Much!

    You might try clearing the Dreamweaver cache: http://forums.adobe.com/thread/494811

  • When to use JAR files

    We are having a discussion at work about the proper usage of jar files. I am fairly opinionated and need to get some good feedback on when jar files make sense.
    Network:
    We have a unix based network as well as a windows based network. We can share samba mounted drives and allow windows access to the class files on the unix network. Most of our internal webservers are on the unix platform.
    We use java in applications, servlets, and JSP's. We have also designed an electronic technical manual that will be deployed via internet and cd rom.
    My first contention that jar files are not needed in the Servlet environment. The class files are virtually local and file storage is not an issue.
    My second contention is that applications running on windows machines would have better performance from local jar files, but the benefits are outweighed by the need to rebuild and reinstall the jar files to ensure the applications behaved the same on both systems.
    My third contention is that the technical manual on cd is a very good candidate for use of jars. We have a limited amount of space to store the files on a cd. We would probably use the jars to serve the information to ensure the behavior of the manual is the same whether the application was access via the CD or the internet.
    What am I missing? Is my understanding of JAR files out of whack with reality?

    Jar files (and their siblings i.e. Wars, Ears) make a
    good unit of deployment. It is much easier to keep
    track of a few jars than a bunch or classes.We have classes which are used in several applications. Ie, A bean queries our bill of material. It is used in an engineering, a manufacturing and a planning application. It can also be used in a jsp. If that bean changes, we would have to deploy three new jar files. If we run from one directory structure, a simple compile fixes all three applications.
    With the samba mounts, we can get to the directory from windows and most flavors of unix.
    We actually have two directory structures. One for production and one for test. Developers usually have another copy stashed somewhere for development purposes.
    I don't know where you get better performance. The
    jar needs to be unzipped which can only slow
    performance. Rebuilding a jar is easy (get Ant) and
    reinstalling a jar is easier than installing a buch of
    class files and resources (see above.) In addition,
    you can seal jars which gives you some level of
    protection (though superficial) and you can set up the
    jar so that it knows the main class.For the most part, these are internal applications, so security is not the top priority. Jars would be nice as they should generate less network traffic due to their smaller size.
    A jar is really just a zip file with a special
    structure. This is really a question of whether you
    need compression. If you can't fit everything onto a
    single CD then compression can help. A plain old zip
    file would work just as well.The compression is the main reason for the techpub application using the jar files. Space on the CD is a concern. Also, for internet access, bandwidth is also a concern. IE, less bits to shove down the wire.
    Like I said before jars are a convienient way to keep
    things organized. You can send out a program in a
    single unit that has everything it needs to run.I have an aversion to anything which requires an install on the users box. This probably comes from working with a bunch of unix hacks that have our system tuned to the nth degree. Much easier to deploy to one central location. No worries about whether or not someone turned their machine off before the nightly push, who has admin rights, etc. Map to the drive and you are off and running. One big performance hit is running the jvm from a shared drive. The JVM should be installed locally.

  • There are some strange problems when i used swc files in my as3 project

    Hello everyone,
            My development environment:  fdk4.0,  flash cs5.5,  I publish fla file by using flash cs5.5,   publish setting is  fp version :10.0&10.1 ->swc. I imported swc files to my as3 project and  complied them by using flex sdk4.0. When i run my project,fp was crash.   when i republished on fp 10.2, the project works. Is there any reason?
            another strange problem, for example   a MovieClip's aslink named "A" in swc, it has a textfield named "subText".  I write code like below:
                            var mc:A = new A();
                            mc.subText.text = "test";  
             when mc called "subText" , fp throws null property error, it can't find  subText..  very small number of movieclips have this problem,  I sloved this by duplicating a new one and rename it.
             but i don't  know why ? 
              thank you for your reply.

    I should have figured that out from your original post. I think there is a possibility that your bookmarks/history database (places.sqlite) has a corrupted record. Rather than take drastic action on that immediately, could you do a test? The test is to exit Firefox, rename your existing database, and restart Firefox. Firefox should import your last bookmarks backup. You then could check whether the problem remains or whether you got a clean restore of bookmarks. After the test, assuming you prefer to retain your history, you could undo the procedure and try restoring your bookmark backup into the database to see whether that overwrites the problem record. If not, then we would go back to possible drastic action.
    '''Test procedure''':
    Open your current Firefox settings (AKA Firefox profile) folder using
    Help > Troubleshooting Information > "Show Folder" button
    Switch back to Firefox and Exit
    Pause while Firefox finishes its cleanup, then rename '''places.sqlite''' to something like places_20130614.sqlite. Keep this window open.
    Restart Firefox. By design, Firefox should import your last automatic bookmark backup.
    If you return to the Library dialog, how does it look?
    '''To reverse the test''' (but preserve a backup of your history/bookmark database):
    Exit Firefox
    Delete the newly created places.sqlite file
    Right-click copy and paste the places_20130614.sqlite and rename the copy to places.sqlite
    Restart Firefox and open the Library dialog. Should look like it did a few minutes ago before any changes.
    ''If the test showed no corruption,'' try to restore your last bookmarks backup. The procedure is described in this article: [[Restore bookmarks from backup or move them to another computer]].
    Does any of that get us closer to a solution?

  • CS 6 locks up when encoding using modified files from after effects

    I have not had any problems until I started trying to use a green screen, which has turned out to be a major pain. Ultra key did a good job, but I kept being told the after affects does a better job. My computer is a PC has 32 Gigs of ram a 4 gig video card, I7. I also just downloaded all the latest updates. I imported an AVCHD file after shooting a 30 min lesson on green screen. Had to do a lot of editing to get all put together so there were lots of cuts and I had alot nested sections so I can resize myself with the background to keep the perspective correct. After I had decent success with keying, though I wish it were better, I tried moving each indivdual video clip over to after effects to key in there. It looked like it might have been a little bit better than the using ultrakey. I tried serveral different turtioals, but finally found one that seemed to work pretty good. (BTW if you have a favorite turtorial that you like on keying, please share.)
    Anyways, after taking forever to get all these clip edited in after affects, I wanted to export my completed video so I could see how well it worked. I never got the the chance because no matter what I choose under MPG2 it would lock up around 8%. Even when I tried to get to encode a 2min section of the video, it still locks up. The only way to get out of the program is to force it closed. As I searched for answer to this problem, someone suggested holding he shift key down while you open CS6, but that did not help. BTW the same file exports fine as long as I do not send any of the footage to after effect
    I hop you guys can help because it would be nice to be able to try and use after affects as well so I can at least see if the final result of the keying is better or not.

    I failed to mention that I tried this on another computer as well with a completly different lesson. This time I brought the whole footage in to afteraffects and did the keying and then went back to CS6 and tried to render it, and it locked up my second computer the same way.

  • When I use under file save page as a desktop icon firefox downloads 2 a icon and a folder, how do I get rid of the folder and just keep the icon like in I.E.

    I'm just trying to save my favorite website short cut icon to the desktop instead of using bookmarks for everything. In I.E. you have the option to save to desktop your favorite website and you only get a shortcut icon. but in Firefox if you save your website to your desktop you get both the website icon but also a folder. but if I try to remove or delete the folder it removes the icon also. how in Firefox can I get just a shortcut icon for favorite website but without the folder.

    Hi Panamark,
    The problem has been resolved for me. I am a little fuzzy on how it got fixed.
    I only have 3G, so I think I went to the library to use wi-fi.
    I think I just deleted the stuck apps, and the downloaded them again. You do not have to pay again when you download a previously purchased app.
    It is now August, and fortunately I have not had any stuck apps lately.
    As you may already know, you cannot download an app over 20 MB via 3G.
    I have the Kindle app also. No new updates lately. I only bought one thing using Kindle. It was a guide to iPad that was only $1.99 or so, but it did not really have anything that cannot be found in normal free Apple guide.
    I have borrowed an ebook from the library using Overdrive app. You can choose the ebook version from Kindle.
    I don't have any weather apps.
    Let me know what happened when you get the chance.
    M

  • When to use XML file Datasource

    Hi,
    I would like to know under what scenario we have to use the XML file as a datasource?
    Is it possibe to extract data from a email.
    The client is getting data in email everyday and is it possible to upload this data directly from the email.
    or do i have to convert this data in the form of  a .csv flat file and upload.
    please give an idea if i can use the XML file upload facility provided in BI, whether i can use this in my
    scenario.
    regards,
    man

    Hello Man,
    Please see this doc for sending XML data to BW
    [How to Send XML Data to BW|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/21d8aa90-0201-0010-5e83-a3798b9a5ee0]
    [How to… Push Data into BW from XI|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/18dfe590-0201-0010-6b8b-d21dfa9929c9]
    [SAP BW Data Retrieval|http://www.sap-press.de/download/dateien/939/sappress_sap_bw_data_retrieval.pdf]
    For Transfering data using XML see this SAP Help Page [SOAP-Based Transfer of Data |http://help.sap.com/saphelp_nw04/helpdata/en/fd/8012403dbedd5fe10000000a155106/content.htm]
    Thanks
    Chandran

  • Why can´t I wire the offset input in the Write File Function when I use datalog files ?

    Hi !
    I have a datalog file, in which I save variant data several times in diferents VIs, I runs these randomly, and I would like rewrite only a part of the file, but I can´t wire the offset input in the Write File function to indicates the begins and save the data in the point that I want.
    I need your help thanks.
    Attachments:
    Second Write in a datalog file.vi ‏19 KB

    Hello.
    I THINK that the reason why the offset input is disabled when you are working with datalog files is that you do not know how many bytes each entry of the data structure will ocupy.
    When you have a binary file where you store, for example, an array of double precision floating-point numbers, you know that each number ocupies 8 bytes, so you know that when you want to read the 21st number of the array you need to skip the first 160 bytes (20 numbers x 8 bytes/number).
    However, with datalog files you can store very diverse data structure, usually including strings, like in your case, which means that you do not know how many bytes to skip to be able to read or write to some particular variable of your data structure.
    If what you want to do is to not overwrite the contents of an existing file, but to append to it, what you probably will have to do is read the whole contents, append to the data in your program, and write it all again.
    Hope this helps,
    Alejandro

Maybe you are looking for

  • How do I get rid of "MyStart by IncrediBar"?

    I have not found any way of deleting MyStart from booting up with Firefox. I have no idea how it got into my computer. Please provide some help with this. Thank you............... Rich

  • Routing changes

    Hi Friends, How can we check changes made in Routing for a particular peroid for a plant? CA60/ CA61 is of no use , as it can be used for 1 mat. or for 1 group at a time. Please help. Thanks & Regards, Sandeep

  • HT1688 how can i get my google contacts to sync to my iphone

    I am having problems syncing my google contacts to my iPhone 4s

  • About a Save button

    Hi to all, I have a Datagrid based on a Table. I have also created a button to save new rows or the changes to existing rows, because I would to use a customized button, instead of the Toolbar "Save". How can save both the situations - Insert and upd

  • Hot to copy document items in process order

    is there any settings to copy document items to process order? I have added item categary D in master recipe (BOM of material) of material. But when i create process order for that material, documents items is not getting copied. is any setting is th