ResourceBundle.getBundle()

Hi,
After hours of debugging I can't find the mistake I do try to load a ResourceBundle with the method
ResourceBundle.getBundle( String baseName, Locale loc, ClassLoader cl );everytime I get a MissingResourceException ...
The scenario :
I got three classes who extends an abstract class who for itself extends from ListResourceBundle.
The first class is the default class called "Resources".
The second class is the language class one lets say "Resources_fr".
The third class is the second language class lets say "Resources_se".
So now i try this:
ResourceBundle bundle = ResourceBundle.getBundle( "Resources", Locale.FRENCH, Resources.class.getClassLoader() );the last argument is not important. It does not work anyway...
So what I doing wrong???
I read the API of ResourceBundle several times and can't find the reason why this not work...
I tryed to set the base name param as "Resources.class" - no effect
I tryed to get the resource bundle only with the base name set - no effect
All classes are stored in the same folder in package called res.
Any ideas?
regards,
Olek

I was able to load the resource bundle by doing the following:
The package com.ani.resourceBundle contains all my resourceBundles: MyResource.java, MyResource_en.java etc...
ResourceBundle myResources =
          ResourceBundle.getBundle("com.ani.resourceBundle.MyResource",Locale.ENGLISH);
So it seems the key is to specify the fully-qualified class name, which is a bit strange since all these classes are on the classpath.

Similar Messages

  • How to destroy the resource contained in resourcebundle.getBundle

    Hi
    I have one problem here.
    I m using ResourceBundle class to load the local values
    from portal_local.properties.
    well its works fine but when i make some changes in this file.The changes r not reflected in the result.Resourcebundle reflects the older values cached in it.
    is their any way so that we can destroy that cache contained in resourcebundle and then load the new file again.
    thanks for any help
    Map globalProperties = PropertyUtils.toMap(ResourceBundle.getBundle(global));
    the whole function is like that
    private static Map loadResources(String global, String local) {
    //getTimeStamp();
    Map globalProperties = PropertyUtils.toMap(ResourceBundle.getBundle(global));
    try {
    globalProperties.putAll(PropertyUtils.toMap(ResourceBundle.getBundle(local)));
    } catch (MissingResourceException e) {
    // We only bother with the local resources if the file's present. The
    // getBundle() will fail if portal_local is missing
    return globalProperties;

    My problem is also that the resource bundle cache cannot be cleared.
    1. you can load a propertyfile from classpath (resourcebundle), but it is cached, and read only once.
    2. you can load a propertyfile if there is where your class is, but then users should see java classes, which is not the best i think.
    At last somebody should tell me how to create a user friendly customizable app, which can be modofied by properties at runtime!

  • Jdev 11.1.1.1.0 ResourceBundle.getBundle does not work with xliff files

    Have anyone found a solution for this ?
    You will get the error when you try to retrieve the resource bundle from your backend bean:
    java.util.MissingResourceException: Can't find bundle for base name nls.readsoft, locale da
    /jan
    Edited by: jsteenberg on Aug 24, 2009 4:45 PM

    its clearly says that your PeHome.properties file missing in classpath or in class folder.
    Check your properties file in output location(means class folder) or in class_path.
    If its missing put in output location, then i think you will not get this error.

  • Error-java.util.ResourceBundle.throwMissingResourceException

    hi all,
    im implementing a report for reporting empty filder..
    i got an error while running the report in portal.
    i got this error..
    unexpected error accessing report com.sap.km.reporting.SimpleReport@641ffc: java.util.MissingResourceException: Can't find bundle for base name com.sap.km.reporting.SimpleReport, locale en_IE
                at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:839)
                at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:729)
                at java.util.ResourceBundle.getBundle(ResourceBundle.java:579)
                at com.sap.km.reporting.SimpleReport.getDisplayName(SimpleReport.java:68)
                at com.sapportals.wcm.repository.manager.reporting.monitor.ReportComponent$ReportWrapper.getDisplayName(ReportComponent.java:294)
                at com.sapportals.wcm.repository.manager.reporting.types.RPReportHandler$DisplayNameGen.getProperty(RPReportHandler.java:160)
                at com.sapportals.wcm.repository.manager.reporting.types.RPPropHandler.getProperties(RPPropHandler.java:110)
                at com.sapportals.wcm.repository.manager.reporting.types.RPPropHandler.getProperties(RPPropHandler.java:143)
                at com.sapportals.wcm.repository.manager.reporting.RPPropertyManager.getProperties(RPPropertyManager.java:89)
                at com.sapportals.wcm.repository.ResourceImpl.internalGetProperties(ResourceImpl.java:3699)
                at com.sapportals.wcm.repository.ResourceImpl.internalGetPropertiesExtended(ResourceImpl.java:1343)
                at com.sapportals.wcm.repository.ResourceImpl.getProperties(ResourceImpl.java:1308)
                at com.sapportals.wcm.repository.CollectionImpl.getChildren(CollectionImpl.java:383)
                at com.sapportals.wcm.service.resourcelistfilter.cm.ResourceListFilter.getChildren(ResourceListFilter.java:425)
                at com.sapportals.wcm.rendering.collection.cm.InternalTree.getChildren(InternalTree.java:1868)
                at com.sapportals.wcm.rendering.collection.cm.InternalTree.getFirstCallOpenResources(InternalTree.java:1142)
                at com.sapportals.wcm.rendering.collection.cm.InternalTree.getFirstCallOpenResources(InternalTree.java:1172)
                at com.sapportals.wcm.rendering.collection.cm.InternalTree.buildNewTree(InternalTree.java:704)
                at com.sapportals.wcm.rendering.collection.cm.InternalTree.renderTree(InternalTree.java:852)
                at com.sapportals.wcm.rendering.collection.cm.InternalTree.render(InternalTree.java:546)
                at com.sapportals.wcm.rendering.collection.cm.InternalTree.buildContent(InternalTree.java:2295)
                at com.sapportals.wcm.control.util.components.base.BaseCompositeComponent.buildComposition(BaseCompositeComponent.java:196)
                at com.sapportals.htmlb.AbstractCompositeComponent.preRender(AbstractCompositeComponent.java:33)
                at com.sapportals.htmlb.Container.preRender(Container.java:118)
                at com.sapportals.htmlb.Container.preRender(Container.java:118)
                at com.sapportals.htmlb.Container.preRender(Container.java:118)
                at com.sapportals.htmlb.Container.preRender(Container.java:118)
                at com.sapportals.htmlb.AbstractCompositeComponent.preRender(AbstractCompositeComponent.java:34)
                at com.sapportals.htmlb.Container.preRender(Container.java:118)
                at com.sapportals.htmlb.Container.preRender(Container.java:118)
                at com.sapportals.htmlb.Container.preRender(Container.java:118)
                at com.sapportals.portal.htmlb.PrtContext.render(PrtContext.java:413)
                at com.sapportals.htmlb.page.DynPage.doOutput(DynPage.java:237)
                at com.sapportals.wcm.portal.component.base.KMControllerDynPage.doOutput(KMControllerDynPage.java:130)
                at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:129)
                at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134)
                at com.sapportals.wcm.portal.component.base.ControllerComponent.doContent(ControllerComponent.java:73)
                at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
                at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
                at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
                at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
                at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
                at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
                at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:646)
                at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
                at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
                at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
                at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
                at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:240)
                at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:522)
                at java.security.AccessController.doPrivileged(Native Method)
                at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:405)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                at com.sap.engine.services.servlets_jsp.server.servlet.InvokerServlet.service(InvokerServlet.java:156)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
                at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
                at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
                at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
                at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
                at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
                at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
                at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
                at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
                at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
                at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
                at java.security.AccessController.doPrivileged(Native Method)
                at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:95)
                at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:160)
    could anyone provide me a solution for this..
    Regards,
    Vinoth

    See Error -Can't find bundle ,locale en_US

  • ADF Groovy Expression with bind variable and ResourceBundle

    Now I have ViewObject which have WHERE clause with bind variable.
    This bind variable is for language. Within bind variable I can change Value Type to Expression and into Value: I put +(ResourceBundle.getBundle("model.ModelBundle")).getString("language")+.
    Now if I run Oracle Business Component Browser (on AppModule) this works. In my ModelBundle.properties there is language=1 name-value pair. And with different locale I have different language number.
    Now if I put that ViewObject on one JSF, this bind variable expression does not work any more. Error:
    *oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.util.MissingResourceException, msg=Can't find bundle for base name model.ModelBundle, locale my_locale*
    Any ideas?
    10x
    Zmeda

    The most wierd thing is that, if I make ViewObjectImpl and insert this method
    public String getLanguage() {
    return (ResourceBundle.getBundle("model.ModelBundle")).getString("language");
    and call it in Bind Variable Expression Value: viewObject.getLanguage()
    IT WORKS!
    But why with groovy expression it does not work?
    Zmeda

  • How to realize czech texts with ResourceBundles

    Hi!
    I have got a big problem trying to make one of our german applications available in czech.
    We are using ResourceBundles with .properties files for our texts and have now translated them into czech. When loading the bundle by calling:
    ResourceBundle rb = ResourceBundle.getBundle("x.x.x.BundleName", locale);all seems to work and there is no exception thrown.
    But when i try to get any text out of it i.e. by calling:
    rb.getString("name");i get an exception:
    java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key name
    I tryied to use native2ascii with several encodings (Cp1252, ISO-8859-1, ISO-8859-2, UTF-8, UTF-16, ...) but i never got one that realy works the way i want. Most of the encodings i tryied changes some of the special characters in the file but also left some of them so that i can get some translated texts but most of them with boxes or question symbols within. native2ascii with UTF-8 encoding only answers with a sun.io.MalformedInputException in the comand line. UTF-16 initially looked fine cause nearly all special characters was translated into \uXXXX escape sequences but also there i got a problem with one special character: � (hope it will be displayed correctly here). This character seems to annoy the native2ascii tool cause the following characters would also be translated into escape sequences even if this is not necessary. Also i got some question symbols in the GUI again (having the charset in the HTML/JSP file set to UTF-16).
    I don't know why the original translated property file could not be read in getting an exception only when trying to get a text not when loading the file. Another thing confusing me is that all encodings (except UTF-16) that i tryied for the translated file corrupted the file by seperating each character with a blank one (so i.e. name = jm�no appered as n a m e = j m \u00e9 n o).
    Some of the special characters in the translation are: � � � � � (and also some other characters with those symbols).
    Please can anyone help me or does anyone has experiences with translating a (web) project to czech or any similar/related language.
    Thanks a lot
    Juergen

    You also seem to have a problem with using native2ascii. You say that you tried to use it with Cp1252, ISO-8859-1 (among others), but how can you possibly have a Czech file in those code pages? They don't support the Czech characters set. You simply need to know which source code page your file is actually in, and then run native2ascii on the file specifying that encoding. I have never had a problem executing native2ascii on a Czech file, it seems to work just fine - as long as the correct source encoding is used.

  • How to "get object" -- ResourceBundle

    According to the ResourceBundle API:
    ResourceBundle myResources =  ResourceBundle.getBundle("MyResources");Besides getString, ResourceBundle also provides ... a generic getObject method for any other type of object. When using getObject, you'll have to cast the result to the appropriate type. For example:
    int[] myIntegers = (int[]) myResources.getObject("intList");
    {code}
    Elsewhere,
    +getBundle+ attempts to locate a property resource file.
    Does it make sense/Is it possible to +getObject+ from a property resource file? If so, how is the object "expressed" in the property resource file?
    For example, if the resource file looks like
    1=Person
    then the key 1 is associated with the String "Person"
    If
    [code]class Person {
    String firstName;
    String lastName;
    ... }[/code]
    is it possible to associate "1" with a Person object, where firstName is "Foo" and lastName is "Bar"?
    If so, how would it look in the property resource file?
    Thanks in advance,
    C                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    In the resource file, you can save the data like this:
    numberofperson=2
    firstname1=Foo
    firstname2=dummyfirst
    lastname1=Bar
    lastname2=dummylast
    For programming, you can code like this:
    public class Person{
    private String firstname;
    private String lastname;
    public Person(String firstname, String lastname){
    this.firstname = firstname;
    this.lastname = lastname;
    int personNum = Integer.parseInt(myResources.getString("numberofperson"));
    Person personArr[] = new Person[personNum];
    for (int i=1; i<personNum; i++){
    personArr[i] = new Person(myResources.getString("firstname"+i),myResources.getString("lastname"+i));
    }

  • Can't get ResourceBundle from jar.

    Dear all,
    I have problem in geting properties from file included in jar file. I try to do it by calling mthod ResourceBundle.getBundle("bundle"), where bundle.properies is the file in jar. When I run the programm by calling :
    java -jar dist/properties.jar
    I have the following rsult on the console:
    Exception in thread "main" java.util.MissingResourceException: Can't find bundle
    for base name bundle, locale pl_PL
    at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:712)
    at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:683)
    at java.util.ResourceBundle.getBundle(ResourceBundle.java:546)
    In case I run this program, using not jar'ed classes everything is ok.
    P.S. the manifest file of the jar is:
    Manifest-Version: 1.0
    Created-By: Apache Ant 1.5.1
    Main-Class: PropertiesLoader
    Thanks in advance for all answers.
    Daniel Kwieci&#324;&#347;ki

    According to ResourceBundleAPI:
    Calling this method is equivalent to calling
        getBundle(baseName, locale, this.getClass().getClassLoader()),
    except that getClassLoader() is run with the security privileges of ResourceBundleTry this code, it will obtain the application's ClassLoader and will enable the location of the properties file in all the classpath defined for it.
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            resources = ResourceBundle.getBundle(BUNDLE_BASENAME, locale, loader);Good Luck!

  • Problem with ResourceBundle in Jar

    Hi,
    I've written the following class which works perfectly in my program but not when used in the same code but distributed as a Jar file.
    In this case, only the default locale is used on a "Messages.getString" call, even if I swith the local to English...
    I've read that there was a "bug" in the j2sdk1.4.2_05 and I'm using the j2sdk1.4.2_06.
    Do you have any idea ?
    Thanks,
    Marc.
    package com.oxiane.marketing.IHM;
    import java.util.Locale;
    import java.util.MissingResourceException;
    import java.util.ResourceBundle;
    * Classe servant � g�rer les langues Anglaise et Fran�aise pour
    * l'interface.
    public class Messages {
         private static final String BUNDLE_NAME = "Messages" ;
         private static ResourceBundle RES_BUNDLE_FR = ResourceBundle.getBundle(BUNDLE_NAME, Locale.getDefault());
         private static ResourceBundle RES_BUNDLE_EN = ResourceBundle.getBundle(BUNDLE_NAME, Locale.ENGLISH);
            public static String getString(String msg){
                 try {
                      if (Locale.getDefault().getLanguage() == "fr")
                           return RES_BUNDLE_FR.getString(msg);
                      else
                           return RES_BUNDLE_EN.getString(msg);
                 catch (MissingResourceException e){
                      System.out.println(e.getMessage());
                      return "";
         public static void setLocale(Locale loc){
              Locale.setDefault(loc);
         public static Locale getLocale(){
              return Locale.getDefault();
    }

    You should take care of the directory structure according to the package structure.
    I for example have this jar:
    C:\source\java\ebank2_util\smsunlock>unzip -l pro-ebank_sms_unlock.jar
    Archive:  pro-ebank_sms_unlock.jar
    Length    Date    Time    Name
          0  10-28-05  17:27   hu/
          0  10-28-05  17:27   hu/khb/
          0  10-28-05  18:17   hu/khb/smsunlock/
        256  11-07-05  16:33   hu/khb/smsunlock/DButils$MySQLException.class
       4229  11-07-05  16:33   hu/khb/smsunlock/DButils.class
       1700  11-07-05  16:33   hu/khb/smsunlock/GUI$1.class
       2318  11-07-05  16:33   hu/khb/smsunlock/GUI$2.class
        988  11-07-05  16:33   hu/khb/smsunlock/GUI$3.class
       1402  11-07-05  16:33   hu/khb/smsunlock/GUI$mywl.class
       5630  11-07-05  16:33   hu/khb/smsunlock/GUI.class
        818  11-07-05  16:33   hu/khb/smsunlock/LimitedLength_TextField.class
       2452  11-07-05  16:33   hu/khb/smsunlock/Main.class
        900  11-07-05  16:33   hu/khb/smsunlock/MyInputStream.class
          0  11-07-05  16:33   META-INF/
         98  10-27-05  15:53   META-INF/manifest.mf
         90  11-07-05  16:33   hu/khb/smsunlock/properties
      20881                    16 filesAnd the resource is loaded like this from hu.khb.smsu.Main:
    InputStream is = new MyInputStream( Main.class.getResourceAsStream( "properties" ) );

  • Problem for ResourceBundle calling from jsp file

    Hi, I am using WebLogic 5.1 in Solaris 8
              I use java.util.resourceBundle to get the information from a .properties
              file
              I put the properties file in /opt/weblogic/myserver/serverclasses
              When I call the properties file from EJB, It seems to be OK
              But when I call the properties file from JSP using the same script, It said
              the properties files not found
              The Error message is:
              <ServletContext-General> Servlet fail
              ed with Exception
              java.util.MissingResourceException: Can't find bundle for base name
              test.dbini,
              locale zh_TW
              at
              java.util.ResourceBundle.throwMissingResourceException(ResourceBundle
              .java:707)
              at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:679)
              at java.util.ResourceBundle.getBundle(ResourceBundle.java:546)
              at
              jsp_servlet._test._global_95_variable._jspService(_global_95_variable
              .java:85)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
              pl.java:105)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
              pl.java:123)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              textImpl.java:742)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              textImpl.java:686)
              at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
              ContextManager.java:247)
              at
              weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
              a:361)
              at
              weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              PLease Help!!
              Regards,
              Fannie
              

    Hi,
    open dataset file for input in text mode.
    check sy-subrc = 0.
    while sy-subrc = 0.
      read dataset file into wa.
      if sy-subrc = 0.
      append wa to itab.
      else.
        exit.
      endif.
    endwhile.
    close dataset file.
    regards
    Siggi
    PS: check also the F1-help for open, read and close statements!

  • Can ResourceBundle load .properties from files and .jar?

    Hi Guys,
    I'm trying to I18N an application with ResourceBundle.
    Suppose my class look like this:
    package pack;
    import java.util.ResourceBundle;
    public class MyClass {
        public static void main(String[] args) {
            ResourceBundle rb = ResourceBundle.getBundle("Language");
    }This would load the localized string from Language.properties
    And when I pack the class file and Language.properties into a jar. It works fine
    But what I tried to do is to make the ResourceBundle try to load from external file first
    before it load from the jar file so that if I have a new language file I can just drop in the
    NewLang.properties.
    Inside .jar file look like this
    /Language.properties
    /pack/MyClass.class
    /meta-inf/Manifest.mf
    I tried look into some forum and they suggest to include Class-Path in Manifest.mf file
    to include current path like this
    Class-Path: .
    But still, it didn't work. If I include .properties in .jar it will not look outside but if I didn't include
    any .properties it found a properties file.
    How can I achieve this ?

    Dave,
    I reckon you're on the right track... just have to figure out "what's the path to properties file"... I suspect you've got a context problem... not sure... I'm pretty new at this stuff myself.
    So, what's your development environment? O/S, IDE, app/web-server, etc.
    Cheers. Keith.

  • ResourceBundle problem with IE7

    Hi all,
    I have problems getting the correct ResourceBundle from the Locale in my applet using IE7. It works with Firefox2 (and with IE6 as a user told me, I did not test this though). Can anyone help me with this? Below you see relevant code and the output in Firefox and IE7:
      System.out.println("DisplayLanguage: "+currentLocale.getDisplayLanguage());
        res_bundle = ResourceBundle.getBundle("myResources.ApplicationResources", currentLocale);
        System.out.println("Locale in ResourceBundle: "+res_bundle.getLocale().toString());
        System.out.println("DisplayLanguage in ResourceBundle: "+res_bundle.getLocale().getDisplayLanguage());
    Output in Firefox 2:
    DisplayLanguage: Italienisch
    Locale in ResourceBundle: it //correct
    DisplayLanguage in ResourceBundle: Italienisch
    Output in InternetExplorer 7:
    DisplayLanguage: it_it //different from the Firefox output
    Locale in ResourceBundle: de //incorrect, this is the default Locale
    DisplayLanguage in ResourceBundle: Deutsch

    Ok, this is apparently a JSP issue. The Language Code provided by request.getLocale() in the JSP is not the same for every browser:
    in Firefox: de, it (this is what the Locale constructor needs: the ISO-639 language code)
    in IE7, Safari: de_DE, it_IT
    I don't know why this is the case, but now I can use a workaround (i.e. ignore the second part of the language code).
    So, the problem is solved. However, I would be still interested in the reasons for these differences...
    Thanks, Gonzberg

  • - Use of ResourceBundle without Locales

    Hello!
    I'm trying to use a ResourceBundle to store properties that arn't locale-specific - its a sort of look-and-feel type arrangement. The way more specific ResourceBundles inherit properties from more general ones would be really useful, but since its not a locale that's used to pick a particular bundle I'm having trouble working out how I can use it for this purpose.
    Has anybody used ResourceBundles for non-locale specific uses before, or does anyone know of anything else that might be more appropriate?
    Thanks loads for any help!!
    Nicola

    Hello!
    I'm trying to use a ResourceBundle to store properties
    that arn't locale-specific - its a sort of
    look-and-feel type arrangement. The way more specific
    ResourceBundles inherit properties from more general
    ones would be really useful, but since its not a
    locale that's used to pick a particular bundle I'm
    having trouble working out how I can use it for this
    purpose.
    Has anybody used ResourceBundles for non-locale
    specific uses before, or does anyone know of anything
    else that might be more appropriate?
    Thanks loads for any help!!
    NicolaYes, you make up your own Locales with anything you want in place of the language, country, and variant. As long as you're not setting the Locale, it works great!
    ResourceBundle laf = new ResourceBundle.getBundle("skins.properties", new Locale("flavor", "chocolate",""));will get all resources in skins.properties and over-riding entries from skins_flavor_chocolate.properties".

  • Using ResourceBundle and Locale in an Applet

    hello,
    i worked out a little application to use with multilanguage support.
    i wrote two classes so i can start the application within a jar file located on my computer and anotherone to launch it as an applet...
    for development i use Eclipse; when i try to run it in eclipse everything works fine (although i limit the access of the applet!)
    when i try to run the applet in IE i get the error message:
    java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)i did not use the function "System.getProperty("user.dir")" in MY code which is referred!
    so i guess its one of the included packages:
    ResourceBundle | Locale
    how can i solve this problem as its working in the limited access applet in eclipse??
    thanks in advance

    note: i do load the .properties file from the JAR package, not from hdd!
    here is my code
    import java.util.Locale;
    import java.util.ResourceBundle;
    public class Xlocale {
         private Locale locale = Locale.ENGLISH;
         private ResourceBundle thisLocaleRB;
         public Xlocale(String aXlocaleName, String aLocale) {
              setLocale(getLocale(aLocale)); //if you leave this line it won't work *hmm?*
              if (thisLocaleRB == null || getLocale() != thisLocaleRB.getLocale()) {
                   try {
                        thisLocaleRB = ResourceBundle.getBundle(aXlocaleName, getLocale());
                   } catch (Exception e) {
                        //System.err.println(e.getLocalizedMessage()+" ["+System.getProperty("user.dir")+"\\"+aXlocaleName+"_"+getLocale()+".properties]\n");
         public String getString(String key, String dv) {
              String val = thisLocaleRB.getString(key);
              if (val == null)
                   return dv;
              else
                   return val;
         public void setLocale(Locale l) {
              this.locale = l;
         public Locale getLocale() {
              return this.locale == null ? Locale.ENGLISH : locale;
        public static Locale getLocale(String loc)
            if(loc!=null && loc.length()>0)
                return new Locale(loc);
            else
                return Locale.ENGLISH;
    }

  • How to use ResourceBundle

    I have a piece of code which tries to read a property file like this:
    ResourceBundle bundleHandle = ResourceBundle.getBundle("Example");
    Here Example.properties is a file located in another directory which is dynamically constructed
    during deployment. So I don't want to put it within the package.
    My question is: Will the above code work? When running under debugger, this line always fails to
    find the Example.properties even it is there?
    Thanks you your help!

    Here Example.properties is a file located in another directory which is dynamically constructed The following should provide some examples.
         // Method: demonstratePropertyAbsolute()
         * Demonstrates how a property file is used via absolute naming
         * Because the file name starts with a forward slash this
         * will use an absolute path (in the context of the java application)
         private static final
              String MAIN_FILE_ABS = "/BlueGnome/demos/Properties/DemoPropertiesFile.properties";
         static void demonstratePropertyAbsolute() throws Exception
              aProperties = new Properties();
              // Demonstrate what the name is
              // Notice that we use the Properties for the the class
              // reference.  It does not matter what class we use.
              java.net.URL url = Properties.class.getResource(MAIN_FILE_ABS);
              System.out.println("Absolute: resolved name = " + url);
              // Get a stream so we can read it.
              java.io.InputStream is;
              is = Properties.class.getResourceAsStream(MAIN_FILE_ABS);
              if (is == null)
                   throw new Exception("Resource File "
                        + MAIN_FILE_ABS + " not found.");
              // Load the stream
              aProperties.load(is);
              System.out.println("  This is a value from the properties file"
                             + " name = <"
                             + aProperties.getProperty("a.value")
                             + ">");
         // Method: demonstratePropertyPath()
         * Demonstrates how a property file is used via path
         * The file name is basically a system file path (unlike the previous two)
         private static final
              String MAIN_FILE_PATH = "./BlueGnome/demos/Properties/DemoPropertiesFile.properties";
         static void demonstratePropertyPath() throws Exception
              aProperties = new Properties();
              // Demonstrate what the name is
              java.net.URL url = ClassLoader.getSystemClassLoader().getResource(MAIN_FILE_PATH);
              System.out.println("PATH: resolved name = " + url);
              // Get the file.
              // We could just use FileInputStream here.  Then we would have
              // to provide a path that was meaningful to the system like
              //     c:\java\BlueGnome\demos\Properties\DemoPropertiesFile.properties
              // Doing it this way allows us to use generic directory
              // seperators and allows for it to search for the file using
              // the CLASSPATH.  That also allows for it to be in a jar file.
              java.io.InputStream is;
              is = ClassLoader.getSystemClassLoader().getResourceAsStream(MAIN_FILE_PATH);
              if (is == null)
                   throw new Exception("Resource File "
                        + MAIN_FILE_PATH + " not found.");
              aProperties.load(is);
              System.out.println("  This is a value from the properties file"
                             + " name = <"
                             + aProperties.getProperty("a.value")
                             + ">");
         }

Maybe you are looking for

  • Tagged PDF in InDesign CS 5.5

    Can anyone point me to a good source for learning about creating tagged PDFs?  I know there are some new options in CS 5.5, but I don't really know what the full process involves.  I know a fair amount about making accessible websites but very little

  • I have 10 B. records in the source i want to load it fast

    Hi Gurus, I have 10B. records in my source now this is my first load. to load the records fast what are the steps i need to do?? Please let me know ASAP.. Thanks Kiran Kumar

  • Web Service in SAP

    Hi, I would like have knowledge about Webservice in SAP ??? Is this the rite area to ask...if yes please provide an insight about Web Service development in ABAP..how effective is t....If not the rite palce please tell in which specifc forum i shoud

  • Adobe Reader 9 after download problem.

    I have downloaded reader 9 numerous times but each time I am unable to open it or any of my other progames, on cliking to open I get the following message: "This file does not have a programe associated with it. For performing this action create an a

  • Spool File not complete when spool recipient recieves email

    Hi, This is my Issue... We scheduled one of the Std SAP report (RLS10020/LX02). When defining the job, we have also specified a spool recipient and once the job was completed, the recipient got the spool as a html file. The spool actually had 15000 l