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

  • Home
  • SEARCH
  • 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 969543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:39:31+00:00 2026-05-16T02:39:31+00:00

I’m testing Java’s i18n features and have a problem, I can’t load the language

  • 0

I’m testing Java’s i18n features and have a problem, I can’t load the language file when it’s not in the class root. Right now my files are in the /lang directory.

Looked several answers here in SO, putting it in a classes subdir and loading it like lang.Messages, used complete location routing /Test/lang/Message (test is the project name), using just /lang/Message and still I’m getting the:

java.util.MissingResourceException: Can't find bundle for base name

error.

Anything else to try?

My file structure is:

Test/lang/Messages_es.properties

Test/src/test/Main.java

import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.JFrame;

public class Main {

     public static void main(String[] args) {

    Locale currentLocale;
    ResourceBundle messages;

    currentLocale = new Locale("es");

    messages = ResourceBundle.getBundle("Messages", currentLocale);
    System.out.println(messages.getString("Messagesgreetings"));
    System.out.println(messages.getString("Messagesinquiry"));
    System.out.println(messages.getString("Messagesfarewell"));
    }
}
  • 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-05-16T02:39:31+00:00Added an answer on May 16, 2026 at 2:39 am

    You need to have your locale name in your properties file name.

    Rename your properties file to Messages_es.properties

    Since you haven’t declared any package, both your compiled class file and the properties file can be in the same root directory.

    EDIT in response to comments:

    Lets say you have this project structure:

    test\src\foo\Main.java (foo is the package name)

    test\bin\foo\Main.class
    

    test\bin\resources\Messages_es.properties (properties file is in the folder resources in your classpath)

    You can run this with:

    c:\test>java -classpath .\bin foo.Main
    

    Updated source code:

    package foo;
    import java.util.Locale; 
    import java.util.ResourceBundle;
    import javax.swing.JFrame;
    
    public class Main {
    
      public static void main(String[] args) {
    
        Locale currentLocale;
        ResourceBundle messages;
    
        currentLocale = new Locale("es");
    
        messages = ResourceBundle.getBundle("resources.Messages", currentLocale);
        System.out.println(messages.getString("Messagesgreetings"));
        System.out.println(messages.getString("Messagesinquiry"));
        System.out.println(messages.getString("Messagesfarewell"));
      }
    }
    

    Here as you see, we are loading the properties file with the name “resources.Messages”

    Hope this helps.

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

Sidebar

Related Questions

No related questions found

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.