1)Directory structure:
| Build. xml
+ --- Build
|/--- Classes
|/--- Com
|/--- Nana
|/--- Test
| Scrap. Class
|
+ --- SRC
|/--- Com
|/--- Nana
|/--- Test
| Autogen. Properties
| Scrap. Java
2)Problem description:
Resourcebundle RB = resourcebundle.Getbundle("Autogen. properties", locale.Getdefault());
Exception in thread "Main" Java. util. missingresourceexception: Can't Find bundle for base name autogen. properties, locale zh_cn
At java. util. resourcebundle. throwmissingresourceexception (unknown source)
At java. util. resourcebundle. getbundleimpl (unknown source)
At java. util. resourcebundle. getbundle (unknown source)
At com. Nana. Test. autogen. Main (autogen. Java: 25)
3)Solution:
1. These resource properties files are loaded by classloader, which is similar to java files. Therefore, you should add these files to classpath.
2. resourcebundle. getbundle ("com. Nana. Test. autogen") tells the classloader to load a resource named "autogen" and the package named "com. Nana. test ".
3. if you do not want to write the package name, you can directly obtain autogen. properties, you need to set autogen. copy the properties file to the classes/COM/Nana/test/directory, together with the class file that calls it.
Resourcebundle RB = resourcebundle.Getbundle("Autogen", locale.Getdefault());