java.util.MissingResourceException in Resource bundle

Hello All, I am creating a ResourceBundle to load the property files. My file structure looks like

| ---Main

   |
    ----ResourceBundleLoad.java

| --Resource

   |
    --- resourcebundle.properties

In normal when i put main class and the property file in same package means it retrieves all the property file values. If i separate both files means it's not working. It throws java.util.MissingResourceException exception.

My code is

 private static final String BUNDLE_NAME = "ExternalizedLogMessages";
 private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);

Please suggest me how to solve this problem

Answers


I achieve this by using the class loader. the source is

 private static URLClassLoader resourceLoader= null;

/**
 * Initialize class loader.
 */
static{
    ClassLoader currentThreadClassLoader
     = Thread.currentThread().getContextClassLoader();

    //assuming that current path is the project directory
    try {
        resourceLoader
         = new URLClassLoader(new URL[]{new File(".").toURI().toURL()},
                              currentThreadClassLoader);
    } catch (MalformedURLException e) {
        logger.error(e);
    }   
}

/**
 * Properties bundle name.
 */
private static final String BUNDLE_NAME = "resource.ExternalizedLogMessages"; //$NON-NLS-1$

/**
 * Resource bundle object.
 */
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
        .getBundle(BUNDLE_NAME,Locale.US,resourceLoader);

Need Your Help

is there any difference if thread is waiting for monitor to be freed before synchronized block or if it calls wait()

java multithreading wait synchronized notify

I've read many docs about thread states, some of them tells that there is two different states: blocked (before synchronized) and wait (if calls wait), some others are telling that there is only one

how to pass a string value into a gridview in C sharp

c# asp.net visual-studio-2008

hey i have a query.... i have extracted data from database..currently that information is in a string variable...my point is to pass that string value into a gridview in the application..i have al...