• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Unable to load Message Resource Bundle with method ResourceBundle.getBundle

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a problem in loading the resource file with the method ResourceBundle.getBundle if i am putting the property file outside the src folder.
What i am thinking that it is not a good idea to keep the property file with java source file or with class files in jar file. so actually i want to give the path of the property file through system property via command line when need to run the code.
but as i am trying it is not accepting the path for the file specified like C:/MessagingBundleAmazon
It is giving

Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name C:/MessagingBundleAmazon, locale en_US

Please help me how we can specify the path name in the base name for the argument.

Thank you
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe the property file should be located somewhere in the classpath. If set your classpath to where the property file
is it should work..
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The name of the class says it all: ResourceBundle. That means that it loads resources, not files. Resources are always located in the class path.

What you can try is use a different class loader. ResourceBundle.getBundle is overloaded to take one. Construct a URLClassLoader for the folder the resource is located in:
This class loader basically extends the class path with the folder (but only when this specific class loader is used).
 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic