This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

File access standards  RSS feed

Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something I've been wondering about for a while. If I'm trying to access a properties file I'll include it's path in my code. But ideally, it's nice to have a properties file that stores the path location of other files. Where will it stop? What can I do so I don't have to hardcode any path into my software? Is there a standard location where the jvm looks for files if there's no specific path provided?
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really. You can write your app to whatever default you want. What I would typically do is offer a command-line option so the user can specify a props file when starting the app:
java MyClass -p C:\Java\misc\foo\bar\
If the user doesn't specify a props file, you can specify a default behavior, such as looking for a file called in the current directory, or in the user's home directory (System.getProperty("user.home")). If no such file is found, maybe bring up a dialog asking the user "hey, where's the damn props file?" or some such (with a "create new configuration" option that leads to a new configuration wizard). Lots of choices, depending how user-friendly you want the whole thing to be, and how much time you want to put into it.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!