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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:57:24+00:00 2026-05-23T17:57:24+00:00

I have a property file which is inside a default package and the class

  • 0

I have a property file which is inside a default package and the class in which I am using the properties file is also in the same default package. If I use just the file name without any path I am getting error. Obviously that is not correct as I should give some kind of path to refer to tat file. I will build the application make it as a jar file so how should I give the path as the properties file should go inside that jar file. I am using Netbeans IDE.

EDIT

 Properties pro = new Properties();

    try {            
        pro.load(new FileInputStream("pos_config.properties"));
        pro.setProperty("pos_id", "2");
        pro.setProperty("shop_type", "2");
        pro.store(new FileOutputStream("pos_config.properties"), null);
        String pos_id = pro.getProperty("pos_id");
        if(pos_id.equals("")){
           pos_id="0" ;
        }
        global_variables.station_id = Integer.parseInt(pos_id);
        String shop_type = pro.getProperty("shop_type");
        if(shop_type.equals("")){
           shop_type="0" ;
        }
        global_variables.shop_type = Integer.parseInt(shop_type);
    } catch (IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
  • 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-23T17:57:25+00:00Added an answer on May 23, 2026 at 5:57 pm

    Use getClass().getResourceAsStream("foo.properties")

    But note that using the default package is discouraged (the above will work with any package).

    Your code doesn’t work because the FileInputStream(..) uses paths relative to the current user directory (see java.io.File documentation). So it looks for foo.properties in /home/usr/ or c:\documents and settings\usr. Since your .properties file is on the classpath you can read it as such – throug the Class.getResourceAsStream(..) method.

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

Sidebar

Related Questions

If I have a Resource bundle property file: A.properties: thekey={0} This is a test
I have a class isSearching with a single boolean property in a 'functions' file
I have a data structure object which is loaded from an XML file inside
I have a Property File like this: frame.server.dev=mark.is.cool frame.server.test=chris.is.cool frame.server.qa=mitch.is.cool frame.server.prod=cory.is.cool I need to
I have property management application consisting of tables: tenants landlords units properties vendors-contacts Basically
I have two collections which have property Email in both collections. I need to
I am trying to add a dependency to a class property using Unity Configuration
Is there a way in ant to load properties from inside a zip file?
I have this file uploader inside an iframe, but when I embed it to
I have a Lazy<List<T>> where T is a class which has a huge string

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.