an environment handle with default attributes. Environment env = new Environment(home, new EnvironmentConfig()); or
Environment env = new Environment(home, null);
Note that many Environment objects may access a single environment.
To create an environment or customize attributes, the application should customize the configuration class. For example:
EnvironmentConfig envConfig = new EnvironmentConfig(); envConfig.setTransactional(true); envConfig.setAllowCreate(true); envConfig.setCacheSize(1000000); Environment newlyCreatedEnv = new Environment(home, envConfig);
Note that environment configuration parameters can also be set through the <environment home>/je.properties file. This file takes precedence over any programmatically specified configuration parameters so that configuration changes can be made without recompiling. Environment configuration follows this order of precedence:
- Configuration parameters specified in <environment home>/je.properties take first precedence.
- Configuration parameters set in the EnvironmentConfig object used at Environment construction are next.
- Any configuration parameters not set by the application are set to system defaults, described along with the parameter name String constants in the EnvironmentConfig class.
An environment handle is an Environment instance. More than one Environment instance may be created for the same physical directory, which is the same as saying that more than one Environment handle may be open at one time for a given environment.
The Environment handle should not be closed while any other handle remains open that is using it as a reference (for example, {@link com.sleepycat.je.Database Database} or {@link com.sleepycat.je.Transaction Transaction}. Once {@link com.sleepycat.je.Environment#close Environment.close} is called, this object may not be accessed again.