General J2EE: How to load or bundle property file in an java application

  1. Dear All,

    I have deployed my application in Oracle Application Server 10g. In my application i am trying to bundle the property file, but it throws the error "Can't bundle the property file".

    I tried to put my property file in root folder of my application, same folder where i am bundle the property and home folder of the application server, but it throws the error "Can't bundle the property file".

    Below is my code:

    Properties ret = new Properties();
    ResourceBundle rb= ResourceBundle.getBundle("XXX.properties);
    for(Enumeration temp=rb.getKeys();temp.hasMoreElements();)
    String onekey=new String((String)temp.nextElement());
    return ret;

    Can any one help me to fix this problem.

  2. 1. Put your properties file somewhere in your server's classpath. For example:


    2. Load the file using a fully-qualified class name (replacing "/" with ".") omitting (a) the classpath directory and (b) the file extension:

    ResourceBundle bundle = ResourceBundle.getBundle("resources.Example");

    See the documentation for the ResourceBundle.getBundle() method for details.
  3. I have tried as what you have mentioned, but its not able to bundle.

    Could you please tell me where to set the directory-class-path for the oracle application server 10g

  4. properties[ Go to top ]

    Hello , I have the same problem and add the directory that contains my properties file and it works .

     public SplitPaneDemo() {
            //Read image names from a properties file
            ResourceBundle imageResource;
            try {
                imageResource = ResourceBundle.getBundle("imagenames");
                String imageNamesString = imageResource.getString("images");
                imageNames = parseList(imageNamesString);
            } catch (MissingResourceException e) {
                System.out.println("Can't find the properties file " +
                                   "that contains the image names.");
    where imagenames.properties is in a directory that I added to my classpath.

    Hope this help you