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 9181335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:17:19+00:00 2026-06-17T18:17:19+00:00

How to switch from ResourceBundle to Properties (class)? I have an app split into

  • 0

How to switch from ResourceBundle to Properties (class)?

I have an app split into 2 Java projects (core & web). A Java service in the core module have to read values from a .properties file located in the web module.
When I use ResourceBundle, it works as expected.

I wanted to switch to the Properties class for several reasons (esp. because the ResourceBundle is cached and I don’t want to implement the ResourceBundle.Control to have no cache).
Unfortunately I can’t get it to work, particularly because I can’t find out which correct relative path to use.

I read the decompiled ResourceBundle class (et al.) and noticed the use of getResource() on some ClassLoader.
So instead of directly using FileInputStream, I tested with getResource() or simply getResourceAsStream() on ServiceImpl.class or ResourceBundle.class but still no success…

Anyone having an idea how to get this work? Thanks!

This is my app core with the service getting the property values:

app-core
    src/main/java
        com.my.company.impl.ServiceImpl

            public void someRun() {
                String myProperty = null;
                myProperty = getPropertyRB("foo.bar.key"); // I get what I want
                myProperty = getPropertyP("foo.bar.key"); // not here...
            }

            private String getPropertyRB(String key) {
                ResourceBundle bundle = ResourceBundle.getBundle("properties/app-info");
                String property = null;
                try {
                    property = bundle.getString(key);
                } catch (MissingResourceException mre) {
                    // ...
                }
                return property;
            }

            private String getPropertyP(String key) {
                Properties properties = new Properties();

                InputStream inputStream = new FileInputStream("properties/app-info.properties"); // Seems like the path isn't the good one
                properties.load(inputStream);
                // ... didn't include all the try/catch stuff

                return properties.getProperty(key);
            }

This is the web module where resides the properties file:

app-web
    src/main/resources
        /properties
            app-info.properties
  • 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-17T18:17:20+00:00Added an answer on June 17, 2026 at 6:17 pm

    You should use getResource() or getResourceAsStream() with proper path and classloader.

    InputStream inputStream = getClass().getClassLoader().getResourceAsStream(“properties/app-info.properties”);

    Make sure the file is named app-info.properties, and not something like app-info_en.properties which would be found by ResourceBundle (when the context matches) but not by getResourceAsStream().

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

Sidebar

Related Questions

Here you have my switch from my Class Essaie with the Main() : switch(c)
I want to switch from my app to a web site (http://translate.google.com/) just clicking
I'm considering making a switch from serializing data from my web service endpoint as
I want to Switch from Web Designer to Front End Developer or web developer
I'm currently switch from ubuntu 11.04 (gcc 4.5) to ubuntu 12.04 (but I have
My problem is how to switch from context menu to correct activity. I have
currently I switch from Java to C++ and this is giving me a hard
I want to switch from Java to a scripting language for the Math based
I tried to switch from Java 5 to Java 6 using the update-java-alternatives command
I have been looking at making the switch from SQL TableAdapters to Linq using

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.