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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:31:23+00:00 2026-05-10T19:31:23+00:00

I want to create an ini file to store some settings for my application.

  • 0

I want to create an ini file to store some settings for my application. Is it a good idea to find where the jar file is located and create an ini file there? If yes, then how can I find the location of the jar file?

But if you know a better solution for something like this, I would like to hear some of them.

EDIT: I’m using mac and I want to run the same application in windows. I could write something in the System.getProperty(‘user.home’) directory, but I want to keep the system clean, if the user decides to remove the app. There is no a better way to store the settings file, for example in the same directory with the application?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T19:31:24+00:00Added an answer on May 10, 2026 at 7:31 pm

    You can locate your application directory using the ClassLoader. See: Java: finding the application directory. Rather than an .INI file, use a .properties file – you can load and save this via the Properties class.

    As others have noted, you should not write user settings to your application directory. What if the user does not have write access to the application directory? What if your application is being used by multiple users on the same system at the same time? Neither of these situations are unusual, even on Windows.

    You might still want to load some settings from the application directory – perhaps the administrator has configured default settings there.

    A common convention is to save user settings to the user’s home directory:

    /home/user/.eclipse C:\Documents and Settings\User\.eclipse 

    Although this means you might leave stray files behind, this can be beneficial if the user re-installs the app. Document such things in a README. Here is how to create and get a reference to the directory:

    public static File getSettingsDirectory() {     String userHome = System.getProperty('user.home');     if(userHome == null) {         throw new IllegalStateException('user.home==null');     }     File home = new File(userHome);     File settingsDirectory = new File(home, '.myappdir');     if(!settingsDirectory.exists()) {         if(!settingsDirectory.mkdir()) {             throw new IllegalStateException(settingsDirectory.toString());         }     }     return settingsDirectory; } 

    On unix-like operating systems, starting the directory name with a period (‘.myappdir’) will make the directory hidden. On Windows, it will be located below My Documents, so users will not see the directory unless they go looking for it.

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

Sidebar

Related Questions

I'm coding a theme and i want to create a configuration file (maybe ini)
I want to create a config.ini that exist in Java for C#? Is there
I want to create a Java application bundle for Mac without using Mac. According
I want to create a simple http proxy server that does some very basic
I've got some PHP code that'll create a new file in a set directory:
i've created some Application settings (i.e. not User ) settings in my Visual Studio
I'm discovering python, and I want to create a plug in application, I guess
I have a windows service where in I want to create a file every
I have this ini file. day=Mon time=01:00:00 occurence=weekly taskname=monitorschedule taskrun=C:\monitor.bat I want to have
I want create a drop shadow around the canvas component in flex. Technically speaking

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.