Reputation: 21200
Any default properties file which java can automatcially load?
Upvotes: 4
Views: 8797
Reputation: 140
There is a small library that you can use which will load properties automatically for you: Confucius.
Upvotes: 0
Reputation: 51311
The short answer is no.
The somewhat longer answer starts with a question itself: What should be configured by this file?
For the logging-API of java (java.util.logging) exists a standard-properties-file to configure it. Other frameworks may as well use standard-configuration files. But that always configure only stuff specific for this framework.
If you want to have persistent configuration, you probably want to use the Preference-API. That allows you to save configuration-data, that stays with the user or the JVM.
Upvotes: 6
Reputation: 533492
You can use your own default properties file. You can do it with just few lines.
There is also built in properties, however, these are no simpler, but they are standard.
IMHO Most of the time a plain Proeprties file is used.
This example from the tutorial. This is a more complex example, you can have just one properties file.
// create and load default properties
Properties defaultProps = new Properties();
FileInputStream in = new FileInputStream("defaultProperties");
defaultProps.load(in);
in.close();
// create application properties with default
Properties applicationProps = new Properties(defaultProps);
// now load properties from last invocation
in = new FileInputStream("appProperties");
applicationProps.load(in);
in.close();
Upvotes: 4
Reputation: 6851
You have to load your properties file yourself or pass arguments at command line.
Upvotes: 0