ResourceBundle and Locale ?

Hi All,
Anybody please tell me what is the use of ResourceBundle and Locale ?
Can I use it in my util/Servlet class ?
What is the advantage of using it ?
Please reply soon
Thanks
Harish Pathak

ResourceBundle is a utility class provided by the java.util package which internally uses ClassLoader and loads files which .properties extension.
Incase you wish to make your application Region or Language specific. Then you can use the Locale concept of ResourceBundle and have multiple property files for each region.
You can set the Locale for the ResourceBundle like en_US where region is US and language is en (english) and it will load the appropriate property file.
--- For your information
Gets a resource bundle using the specified base name, locale, and class loader.
Conceptually, getBundle uses the following strategy for locating and instantiating resource bundles:
getBundle uses the base name, the specified locale, and the default locale (obtained from Locale.getDefault) to generate a sequence of candidate bundle names. If the specified locale's language, country, and variant are all empty strings, then the base name is the only candidate bundle name. Otherwise, the following sequence is generated from the attribute values of the specified locale (language1, country1, and variant1) and of the default locale (language2, country2, and variant2):
baseName + "_" + language1 + "_" + country1 + "_" + variant1
baseName + "_" + language1 + "_" + country1
baseName + "_" + language1
baseName + "_" + language2 + "_" + country2 + "_" + variant2
baseName + "_" + language2 + "_" + country2
baseName + "_" + language2
baseName
Candidate bundle names where the final component is an empty string are omitted. For example, if country1 is an empty string, the second candidate bundle name is omitted.
getBundle then iterates over the candidate bundle names to find the first one for which it can instantiate an actual resource bundle. For each candidate bundle name, it attempts to create a resource bundle:
First, it attempts to load a class using the candidate bundle name. If such a class can be found and loaded using the specified class loader, is assignment compatible with ResourceBundle, is accessible from ResourceBundle, and can be instantiated, getBundle creates a new instance of this class and uses it as the result resource bundle.
Otherwise, getBundle attempts to locate a property resource file. It generates a path name from the candidate bundle name by replacing all "." characters with "/" and appending the string ".properties". It attempts to find a "resource" with this name using ClassLoader.getResource. (Note that a "resource" in the sense of getResource has nothing to do with the contents of a resource bundle, it is just a container of data, such as a file.) If it finds a "resource", it attempts to create a new PropertyResourceBundle instance from its contents. If successful, this instance becomes the result resource bundle.
If no result resource bundle has been found, a MissingResourceException is thrown.

Similar Messages

  • 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;
    }

  • Resource Bundles and Locales

    Hi!!
    I am researching Resource Bundles and how they work and have a question. Do you have to use Locales to determine which bundle to use? You see I am developing a product that will only be used in the US but will be used by several different companies. I would like to use a resource bundle for each company instead of for each country!! Is this possible? and if it is, how?
    Thanks for your time

    If you want to have default values, I would suggest using ResourceBundles and just sending in a Locale with the variant of the company. That way if your application ever needs to be localized it won't take much to change it. Your properties files would be named baseName_languageCode_CountryCode_Variant.properties.
    It has been a great advantage for the program that I am developing.

  • Remote and local interface on same ejb 3.0 bean instance

    Hi,
    Is it posible to get remote and local interface on same ejb 3.0 bean instance.
    For example get local interface of a bean and than pass it as remote to client.
    Both interfaces must operate on same bean instance.
    Thanks
    Zlaja

    yes. You can implement multiple interfaces on a single class, so you can add a local and a remote interface. One trick to avoid duplicate code is to simply make the remote interface extend the local interface; then you only have to add the @Remote annotation and you're done.
    For example get local interface of a bean and than pass it as remote to client.You don't pass an instances to a client, a client looks up a remote instance of the bean through JNDI.

  • Remote and local databases

    let say that i access a oracle form through the web and that form access data from two distributed databases, then will there be a remote database and local database for the user or all the databases will be remote databases to the user

    In my opinion.
    using local databases -- access tables without DB_link
    using Remote databases -- access tables through DB_link

  • Remote and Local Site Sync Problems

    I have a customer who is using Dreamweaver CS4 on Mac OS X. Dreamweaver is setup to have a local site as our development server(win 2k3) and the remote site as our live web server(win 2k3). The folder structure on both the development and live web server is the same. When you view the path in the manage site window of dreamweaver it shows both remote and local site listed as /Volumes/www/Data. When dreamweaver connects to both of these to sync the files nothing happens since it sees them as the same place.
    I have looked in the /Volumes folder on the customers computer and two listings appear for the servers www and www-1. This is not what dreamweaver shows and if you repoint the link to the www-1 folder it just changes back to www.
    I have tried to create alias' and symbolic links to distinguish one folder from the other however nothing I seem to change has any effect.
    If you use finder on the machine it can distinguish between the two folders I just need to figure out how to make dreamweaver do the same.
    Any assistance on this would be greatly appreciated.

    Unfortunately no I do not have a solution. I was not able to find out at the time and the problem went away with the migration to a content management system for our web server. Also the Develpment team changed hands and the new people all use windows machines.
    Good Luck trying to find a solution.

  • Performance with globle variable and local var.

    hi anyone
    i just have one performance question about the globle var and local. is having a globle var that is initialized with 'new' at one place better than having local var that is initialzed with 'new' in several places? for example, i have a access var that is initialzed with DB connection. should i have it as a globle var? or put it in the functions where it is needed, and initialize it with DB connection? in both cases, i need to use new operator.
    thanks in advance.

    First , don't use the term "global variable". It is misleading and not an official part of the Java nomenclature. I think the term used should be ( and correct me if I'm wrong ) instance variable. In C and C++ globale variables really are global - they can be accessed by any and all classes which include the header file.
    OK, having got that out of my system, back to the question. The value is gotten from a database, right? Whether you make it an instance variable or not depends on you design and whether the value in the database is likely to change during the lifetime of the instance.
    For example, if this class is a superclass of another, and the cild needs to know the value of the variable, it is often convenient to make it an instance variable so the subclass can access it directly.
    But if the value is likely to change, then you may want to have a getter method which returns the current value in the database.
    The latter will clearly have more overhead associated with it since you would need to get the value each time, but it is probably safer than having an instance variable.

  • How to change value of instance variable and local variable at run time?

    As we can change value at run time using debug mode of Eclipse. I want to do this by using a standalone prgram from where I can change the value of a variable at runtime.
    Suppose I have a class, say employee like -
    class employee {
    public String name;
    employee(String name){
    this.name = name;
    public int showSalary(){
    int salary = 10000;
    return salary;
    public String showName()
    return name;
    i want to change the value of instance variable "name" and local variable "salary" from a stand alone program?
    My standalone program will not use employee class; i mean not creating any instance or extending it. This is being used by any other calss in project.
    Can someone tell me how to change these value?
    Please help
    Regards,
    Sujeet Sharma

    This is the tutorial You should interest in. According to 'name' field of the class, it's value can be change with reflection. I'm not sure if local variable ('salary') can be changed - rather not.

  • Transparent Tunneling and Local Lan Access via VPN Client

    Remote users using Cisco VPN 4.2 connect successfully to a Cisco Pix 515 (ver. 6.3). The client is configured to allow Transparent Tunneling and Local Lan access, but once connected to the Pix, these two options are disabled. What configuration changes are required on the Pix to enable these options? Any assistance will be greatly appreciated.
    Mike Bowyer

    Hi Mike,
    "Transparent Tunneling" and "Local Lan Access" are two different things. "Transparent Tunneling" is dealing with establishing an IPSec Tunnel even if a NAT device is between your client and the VPN-Headend-Device. "Local LAN Access" is dealing with access to devices in the LAN your VPN-Client-Device is connected to.
    What do you mean exactly with "disabled once the connection is made" ?
    You can check the local LAN Access by having a look at the Route-Table of the VPN-Client:
    Right Click the yellow VPN-lock Icon in System-Tray while the VPN-Connection is active and select "Statistics ...". Have a look at the second register page "route details".
    Are any local LAN routes displayed when your are connected ?
    And - always remember two important restrictions the Online Help of the VPN-Client is mentioning:
    1: This feature works only on one NIC card, the same NIC card as the tunnel.
    2: While connected, you cannot print or browse the local LAN by name; when disconnected, you can print and browse by name.
    Carsten
    PS: Removing Split Tunnel won't enable local LAN access as all traffic would be sent into the IPSec tunnel.

  • "The file [name of file] may have been changed by another user since you last saved it." Issue affects both network and local files.

    When a certain user saves a file in Excel 2010, she gets a message: "The file <name of file> may have been changed by another user since you last saved it."  She can choose to save as another file or overwrite with her changes. 
    This just started happening a week or so ago.  She was concerned that someone else was accessing her files, but we did several tests that opened, made a change and saved in a matter of seconds, and she still gets the message.  It happens on
    most files, but not all – both network and local.
    We already tried the QFE_Saskatchewan registry fix.  I also checked the file server for Services for Macintosh.

    You may be confused by the error in Excel saying “another user”. Actually Excel cannot tell who (the real human) is editing the file. Based on my research the No.1 possibility of the error is KB2626998.
    2626998  Connection to a network document is lost in the 2007 Office system or in Office 2010 after the computer resumes from standby
    http://support.microsoft.com/kb/2626998
    For Excel 2010, follow these steps:
    a.  Click Start , click Run , type regedit in the Open box, and then click OK .
    b.  Locate and then select the following registry subkey: HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\Options
    c.  On the Edit menu, point to New , and then click Dword Value .
    d.  Type NetworkAvailableTimeInSeconds , and then press Enter.
    e.  Right-click NetworkAvailableTimeInSeconds , and then click Modify .
    f.  In the Value data box, click Decimal , type a number value, and then click OK .
    Note This registry subkey sets the time, in seconds, that Excel waits for the network to resume. For example, if you type 15 for the number value, Excel waits 15 seconds for the network to resume. You might have to do some tests in your own environment to
    determine an appropriate value. You may have to try multiple numbers.
    g.  Locate and then select the following registry subkey.
    HKEY_CURRENT_USER\Software\Microsoft\office\14.0\common\Internet
    h.  Repeat step 2C through step 2F again. Reuse the same value that you used previously.
    i.  Exit Registry Editor.
    Feel free to post back. Thanks.
    Cheers,
    Tony Chen
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please contact
    [email protected]

  • How to show both SC and Local Currency in PLD at Amount place?

    Hi sir,
    I want to show both System Currency and Local Currency in PLD at the Amount Place.
    And amount in Words also.
    When i preview my PLD Report than it show the both SC and LC in Words.
    So,plz help me sir.!

    Hello jyotasna ,
    Docuement total always in one currency depend on selected Customer or Vendor and if you want to in two currency then you should make UDF(User Define Field) for other currency.
    also make FMS for calculation in this UDF .
    If you want to amount in word in PLD then you should use ,select option Amount in  words
    for this configuration  you should need workaroud.
    Thanks
    Manvendra Singh Niranjan

  • Can external users change their language, time zone, and locale settings?

    Hi,
    We’re migrating our hosts from WebEx cloud to our on-prem solution right now (CWMS 1.5.1.323.A).
    We’ve learned that CWMS 1.5 does not provide an online address book where hosts could customize language, time zone, and locale settings for their external attendees.
    Do external users have any chance at all to change their language, time zone and locale settings individually?
    Thank you,
    Helge

    Hi Dejan,
    "external users" are those participants, who do not have an LDAP account in our deployment, since they are not intendet to act as hosts: our stakeholders, partners, customers, clients.
    It looks, as if these people would stick to the systems' default language / time zone / locale.
    We are wondering if there might be a CWMS-component like this:
    https://artcom.webex.com/cmp0307l/webcomponents/widget/preference.do?serviceType=MC&siteurl=artcom&target=Page&backUrl=%2Fmw0307l%2Fmywebex%2Fdefault.do%3Fsiteurl%3Dartcom%26service%3D1
    to allow those "extenal" participants to make their adjustments.
    Thank you,
    Helge

  • BOXI3.0: Universe and Local Data Source Selection

    Hi all. I am Alias.
    I have one question. For the full XI3.0 installation, one of the products is Web Intelligence Rich Client.
    In Web Intelligence Rich Client, we can have Data Source Selection which is Universe and Local Data Source. But for Web Intelligence/InfoView, we can only select universe, or maybe canu2026 I need to explore more but still could not find it.
    Hope you guys can help me on this matter.
    Best regards,
    Alias

    Hi Jacques.
    Thanks for the link.
    WRC we need to install for every user desktop right? But for Webi/inforview we only install at server.
    In term of licensing, how it works?
    Regards,
    Alias

  • Globle and local Inventory

    Hi:
    I know there are global inventory and local inventory. the global inventory is pointed by oraInst.loc. Where is local inventory? THX

    Please see these MOS docs, it should answer your question.
    Global and Local Inventory explained [ID 360079.1]
    How to find the location of GLOBAL Inventory and LOCAL inventory on R12.x ? Need Clarifications Oracle Inventory [ID 878717.1]
    How to create, update or rebuild the Central Inventory for Applications R12 [ID 742477.1]
    Thanks,
    Hussein

  • SEM -BCS Trasaction currency and Local Currency

    SAPGURUS
    I have one issue , When the users are doing Half yearly BCS they see  that for one company code for one item period values Local currency is diifeernt from
    Transaction currency .
    My question is why this Transaction currency is different from local currecny.
    How to rectify this .
    Are they  missing any exchnage rate conversion .
    Thanks in Advance .
    are they  missing any exchnage rate conversion .

    Hi Dan Sullivan
    Thanks for the quick reply .
    One more question .
    I see in the BCS  T Curency as Euro and Local currency as Euro .
    but the period values localy currency is different from Transaction currency .
    I think the values should be the same if both T Currecny and Local Currency is same .
    I also observed that this particular difference is happening only for 2 particular set of accounts . Those accounts are related to Intercompany related G L Accounts values .
    I also observed that in the Break down category for these G L Accounts The break down structure category has defined as defaulted .
    I would like to know what would be the cause for the above .
    Thanks in Advance .
    Ravindrareddy.P.

Maybe you are looking for