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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:09:13+00:00 2026-05-11T14:09:13+00:00

I have a .jar file I’m putting together. I want to create a really

  • 0

I have a .jar file I’m putting together. I want to create a really really simple .properties file with configurable things like the user’s name & other stuff, so that they can hand-edit rather than my having to include a GUI editor.

What I’d like to do is to be able to search, in this order:

  1. a specified properties file (args[0])
  2. MyApp.properties in the current directory (the directory from which Java was called)
  3. MyApp.properties in the user’s directory (the user.home system property?)
  4. MyApp.properties in the directory where the application .jar is stored

I know how to access #1 and #3 (I think), but how can I determine at runtime #2 and #4?

  • 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. 2026-05-11T14:09:13+00:00Added an answer on May 11, 2026 at 2:09 pm

    #2 is the ‘user.dir’ system property. #3 is the ‘user.home’ property.

    #4 is a bit of a kludge no matter how you approach it. Here’s an alternate technique that works if you have a class loaded from a JAR not on the system classpath.

    CodeSource src = MyClass.class.getProtectionDomain().getCodeSource(); if (src != null) {   URL url = new URL(src.getLocation(), 'MyApp.properties');   ... }  else {   /* Fail... */ } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jar file that I want to put in the shared lib
I have a jar file that I would like to execute using PHP, but
I have a jar file on my filesystem and I want to update a
I have several JAR file pattern sets, like <patternset id=common.jars> <include name=external/castor-1.1.jar /> <include
I have a .jar file which has a command line interface. I want to
I have a jar file. I want to know which external classes and methods
Let's say that I have a jar file @ /usr/local/apps/app1/java/file.jar . I would like
Basically, I have a jar file that i want to unzip to a specific
I have a jar file exporting some functions which i want to use in
I'd like to have a jar file in which only the API package is

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.