Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7846095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:27:52+00:00 2026-06-02T17:27:52+00:00

I’m working on localization for a program I’ve written with a couple other guys.

  • 0

I’m working on localization for a program I’ve written with a couple other guys. Most of the strings now load in the appropriate language from an ini file. I’m trying to do the same with the format of currency in the program. However, I’m getting a runtime exception as soon as I attempt to launch the application.

I’m using the Locale object as a parameter to a few NumberFormat.getCurrencyInstance()’s, like so:

private static final NumberFormat decf;
static 
{
    decf = NumberFormat.getCurrencyInstance(Lang.cLocale);
    decf.setRoundingMode(RoundingMode.HALF_UP);
}

Lang is the class which contains all the localization stuff. The code the IDE complains about at attempted runtime is public static Locale cLocale = new Locale(GUI.DB_info[19],GUI.DB_info[20]);

GUI is the class the GUI is contained in, and where we decided to construct the DB_info array (which itself just contains information loaded from a remote database in another class). DB_info[19] is the language code (es right now) and DB_info[20] is the country code (US). The array elements are being properly filled– or were, I can’t get far enough into the program to tell right now; but nothing has changed with the code for filling DB_info.

The full exception is as follows:

Exception in thread "main" java.lang.ExceptionInInitializerError
at greetingCard.GUI.<clinit>(GUI.java:118)
Caused by: java.lang.NullPointerException
at java.util.Locale.<init>(Unknown Source)
at java.util.Locale.<init>(Unknown Source)
at greetingCard.Lang.<clinit>(Lang.java:13)
... 1 more

The line in GUI referenced is: static String welcome = Lang.L_WELCOME + ", " + empName;, and Lang.java basically looks like this:

// Set locale for currency display
public static Locale cLocale = new Locale(GUI.DB_info[19],GUI.DB_info[20]); // language, country

// Employee specific strings
public static String L_AMT_REMAIN = "";
public static String L_AMT_TEND = "";
public static String L_APPROVED = "";
public static String L_ARE_YOU_SURE = "";
[...]

public static void Main(String emp_lang)
{
    String header = "";

    if (emp_lang.equals("ENG"))
    {
        header = "ENG";
    }
    else if (emp_lang.equals("SPA"))
    {
        header = "SPA";
    }
    else if (emp_lang.equals("FRE"))
    {
        header = "FRE";
    }
    else if (emp_lang.equals("GER"))
    {
        header = "GER";
    }
    else
    {
        header = "ENG";
    }

    try 
    {
        Ini ini = new Ini(new File("C:/lang.ini"));

        L_AMT_REMAIN = ini.get(header, "L_AMT_REMAIN");
        L_AMT_TEND = ini.get(header, "L_AMT_TEND");
        L_APPROVED = ini.get(header, "L_APPROVED");
        L_ARE_YOU_SURE = ini.get(header, "L_ARE_YOU_SURE");
                    [...]
                                L_WELCOME = ini.get(header, "L_WELCOME");
        L_WELCOME2 = ini.get(header, "L_WELCOME2");
        L_XACT_CHNG = ini.get(header, "L_XACT_CHNG");  
        L_YES = ini.get(header, "L_YES");

        System.err.println("Employee Language: " + header);
    } 
    catch (InvalidFileFormatException e) 
    {
        e.printStackTrace();
    } 
    catch (IOException e) 
    {
        e.printStackTrace();
    }
} // end public static void main

That’s for the majority of the strings to be displayed in different languages. There is another method inside Lang that loads some other strings, independent of the first set. I don’t believe it factors into this problem but I can post it if needed.

The order in which these classes/methods get launched is as follows:
GUI.Main calls the Login class, which calls a CreateLogin method. That method calls Clients.main, which gets the DB_info array from GUI passed to it. Clients fills the DB_info array. Lang.other is then called (to get language-specific strings for the login page), and the Login buttons and labels are created. Once a login is successful, the perferred language of the employee logging in (from a DB) is passed to Lang.main to load the other strings (hence the emp_lang being passed in the code above).

Up until I added the code for the Locale object, all of this worked fine. Now I get the ExceptionInInitializerError exception. Anyone know what’s going on?

BTW, for loading from the ini file I’m using ini4j. Some forum posts I found while googling suggest this is a problem with that, but I don’t see how it relates to the problem with Locale objects. The ini stuff works (worked) fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:27:54+00:00Added an answer on June 2, 2026 at 5:27 pm

    Sounds like you have a cycle in your static initializers, so something is not initialized yet.

    GUI calls Lang‘s static initializer before getting Lang.L_WELCOME. Lang calls GUIs static initializer in line 2. Your exception trace makes it look like GUI calls Langs static initializer for some reason.

    In all, cycles like this mean that someone is going to reference a statically initialized object and get null instead of what they expected to get. In this case, I suspect Lang.java, line 2, is passing two null pointers to the Locale constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.