Java – eclipse RCP: using the configuration directory
My eclipse RCP application needs a configuration file that contains some information about connecting to a remote database Where is the best place to store this profile?
Can I use the default configuration directory (usually 'config. Ini') for this purpose? If so, how can I programmatically get the file instance to this location? I also noticed that this directory does not exist in my eclipse ide
thank you.
Solution
According to your requirements, you can always use a variety of options
>Use runtime preferences to store the appropriate preferenceinitializer in the preferencestore Quite a large and extensive API has many ideas into it By default, preferences are not exposed to users or administrators, so you need to do some work to expose the Preferences page or write to the properties file
For less advanced / less work, especially if you cannot access eclipse preferences (such as server-side OSGi):
>At RCP Ini as the system property After startup, it cannot be changed by the user and needs to access RCP Ini (eclipse. INI) file, which may be especially if you don't contribute ide. > Set as a system property as a parameter in the shortcut It is up to the user to use the shortcut A dedicated shortcut needs to be generated during installation
If the accessibility of the file system is very important, I will consider using one of the above methods to set the etc directory. If they do not exist when used for the first time, let your bundle generate a default attribute file in the etc directory This is basically scrolling your own preference store, so if you have access to the preference package, you'd better do so This rather old user settings FAQ may also be helpful
I do remember an interview with Erich gamma (such as the Quartet and JDT technical director). He said that there were about seven different preference mechanisms, and he never knew which one to use