Java.util.MissingResourceException

When starting the application, I get below the exception. This application reads the abc.properties file,

Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name abc, locale en_US
    at java.util.ResourceBundle.throwMissingResourceException (ResourceBundle.java:853)
    at java.util.ResourceBundle.getBundleImpl (ResourceBundle.java:822)
    at java.util.ResourceBundle.getBundle (ResourceBundle.java∗66)
    at com.ibm.dst.DailyExtract.getResourceBundle (DailyExtract.java:104)
    at com.ibm.dst.DailyExtract.main (DailyExtract.java:131)

The abc.properties file is in the workspace. I use RSA7 as an IDE, is there a configuration problem? Any suggestions are welcome .....

Thank you very much in advance

+5
source share
6 answers

Follow the prompts in this post and see if one of the mistakes that might be made has been made (copy to the link):

  • These resource property files are loaded by a class loader similar to java classes. Therefore, you need to include them in your path to the execution path.

  • These resources have a fully qualified resource name, similar to a full-screen class name, you cannot import a resource into your java source file. What for? because his name takes the form of a string.

  • ResourceBundle.getBundle("config")tells the classloader to load a resource named "config" with the default package (that is, without the package). This does NOT mean a resource in the current package that has a reference class.

  • ResourceBundle.getBundle("com.cheng.scrap.config") "config" "com.cheng.scrap". -- "com.cheng.scrap.config"

+11

, "ABC.properties" a.b.c,

ResourceBundle labels = ResourceBundle.getBundle("a.b.c.ABC");
+2

, .

:

bin 
  - com 
     - brookf 
        - all my packages here. 

bin.

+2

. org.example.com.foobar abc, org.example.com.foobar. (, ), , .

, .java, -

private static ResourceBundle RES = ResourceBundle.getBundle(NameOfTheCurrentClass.class.getCanonicalName());
+1

? , abc_en_US.properties

0

I had the same problem today and it took me a while until I figured out what to fix (I use Eclipse as an IDE). My project folder contains * .properties-Files in the following path:

project/src/strings

Since the strings are a subfolder of src, and src is already in the build path of the project (see the properties window), all I need to do is add an inclusion template for * .properties-Files:

**/*.properties

There should be an inclusion template for * .java-Files (** / *. Java)

Maybe something similar for your IDE

0
source

All Articles