GeeCON Prague 2014*
The moose likes Java in General and the fly likes File access standards Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "File access standards" Watch "File access standards" New topic
Author

File access standards

Paul Keohan
Ranch Hand

Joined: Mar 15, 2000
Posts: 411
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?
Thanks.
Paul
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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\myclass.properties
If the user doesn't specify a props file, you can specify a default behavior, such as looking for a file called myclass.properties 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.


"I'm not back." - Bill Harding, Twister
 
GeeCON Prague 2014
 
subject: File access standards