How to initialize static ResourceBundle?

Discussion in 'Java' started by J. Bayjan, Jan 26, 2004.

  1. J. Bayjan

    J. Bayjan Guest

    Since the static objects are null if they are not initialized. But I
    don't how I can initialize static ResourceBundle.
    code :
    public static ResourceBundle resBundle;

    if i initialize in this way
    public static ResourceBundle resBundle = new ResourceBundle();

    compiler error is like: cannot instantiate from class ResourceBundle
    it is not a concrete class.

    Yes ResourceBundle is abstract class, right? So how can i initialize
    this resBundle variable. Because when I use it again later it gives
    NullPointerException:(.

    Thank you very much for your help!

    Best Regards, J. Bayjan!
    J. Bayjan, Jan 26, 2004
    #1
    1. Advertising

  2. J. Bayjan

    Jim Sculley Guest

    J. Bayjan wrote:
    > Since the static objects are null if they are not initialized. But I
    > don't how I can initialize static ResourceBundle.
    > code :
    > public static ResourceBundle resBundle;
    >
    > if i initialize in this way
    > public static ResourceBundle resBundle = new ResourceBundle();
    >
    > compiler error is like: cannot instantiate from class ResourceBundle
    > it is not a concrete class.
    >
    > Yes ResourceBundle is abstract class, right? So how can i initialize
    > this resBundle variable. Because when I use it again later it gives
    > NullPointerException:(.


    Either instantiate a concrete implementation of the ResourceBundle (such
    as PropertyResourceBundle) or call the appropriate static getBundle()
    method:

    ResourceBundle someBundle = ResourceBundle.getBundle("someBundle");

    Jim S.

    --
    Remove my extraneous mandibular appendages to reply via email.
    Jim Sculley, Jan 27, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marius Hintermann

    ResourceBundle.getStringArray(key)

    Marius Hintermann, Jul 31, 2003, in forum: Java
    Replies:
    0
    Views:
    4,653
    Marius Hintermann
    Jul 31, 2003
  2. iksrazal
    Replies:
    5
    Views:
    4,317
    Lothar Kimmeringer
    Aug 6, 2003
  3. JP
    Replies:
    0
    Views:
    444
  4. Rhino
    Replies:
    2
    Views:
    5,193
    Filip Larsen
    Dec 22, 2003
  5. Dan
    Replies:
    2
    Views:
    3,524
Loading...

Share This Page