The Java tutorial on using properties talks about how to use the Properties class. In the tutorial it shows the properties being written to a file called "defaultProperties". So what is a good name and location for the properties file?
I usually write one of two java applications: a system utility or a user program. I think most system utilities would have a file in /etc/myfile.properties
and most user programs would create a ~/.myfile.properties
. However, these paths would not work in Windows. Is there a more generic way of defining these details to make the code platform independent?
If you are talking about keeping external property file to configure your app then I would suggest
System.getProperty("user.home")+File.separator+ "yourappname"+File.separator+"name.properties"
of if you are talking about property file placed internal to your project keep it in default package
.
OR
other options are using XML file, or Preference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With