Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to store .properties files for Java?

Tags:

java

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?

like image 372
User1 Avatar asked Jan 12 '11 15:01

User1


1 Answers

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

like image 104
jmj Avatar answered Sep 29 '22 02:09

jmj