I know how to find the base directory of an applet. ie. getDocumentBase(); but how do I determine the base directory or where all the files in a standalone application are located? The reason I ask is that I have created a Java software program that will be installed on an end user's machine. I need the program to be able to detrmine the base directory like the getDocumentBase() function for an applet above. It would be nice if they placed it in c:\programName...., but that may not be the case. They may use d:\someOtherFolder\programName.... Many thanks in advance. Brian
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
10
posted
0
The File class provides several methods for navigating a file system. getParent(), getPath(), getAbsolutePath() ...
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Brian Snyder
Ranch Hand
Joined: Feb 03, 2001
Posts: 142
posted
0
Thanks Marylin, I would like to take this a step further. So let's say I create an instance of File. File file = new File(???); How do I know the abstract path name to enter if the file could be different depending on the way the user installed my software? I know it is easy to get the parent directory once a file is known, but what if where it originates (its abstract path) changes with each installation. ie. Some people will install as follows .... c:\Program Some people might install as follows .... d:\Program Maybe I need to write the starting directory in a properties file so the program can read the pathname into the program upon execution??? If so, how can I record that? Thanks again for your help. Brian [This message has been edited by Brian Snyder (edited October 07, 2001).]