dotenv alternatives and similar libraries
Based on the "Configuration" category.
Alternatively, view dotenv alternatives based on common mentions on social networks and blogs.
-
centraldogma
Highly-available version-controlled service configuration repository based on Git, ZooKeeper and HTTP/2 -
KAConf
KickAss Configuration. An annotation-based configuration system for Java and Kotlin -
Configur8
Nano-library which provides the ability to define typesafe (!) configuration templates for applications. -
Gestalt
A Java configuration library that allows you to build your configurations from multiple sources, merges them and convert them into an easy-to-use typesafe configuration class. A simple but powerful interface allows you to navigate to a path within your configurations and retrieve a configuration object, list, or a primitive value.
Access the most powerful time series database as a service
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of dotenv or a related project?
Popular Comparisons
README
dotenv

A twelve-factor configuration library for Java 8+.
Features:
- seamless integration with Guice (prefer Spring? see here);
- zero dependencies;
- available in Maven Central.
Usage
<dependency>
<groupId>com.github.shyiko.dotenv</groupId>
<artifactId>dotenv</artifactId>
<version>0.1.1</version>
</dependency>
ENV resolution order (sources higher in the list take precedence over those located lower):
- System.getenv()
.env
file in current working directory (might not exist).env
file on the classpath
(java example)
Let's assume you have a jar file (say app.jar
) which contains .env file (e.g. printf "SCHEME=http\nHOST=localhost\n# comment\nPORT=8080" > src/main/resources/.env
) and Main.java with the following public static void main(...)
:
Map<String, String> dotEnv = DotEnv.load();
System.out.println(dotEnv.get("SCHEME") + "://" + dotEnv.get("HOST") + ":" + dotEnv.get("PORT"))
Executing the following
printf "HOST=0.0.0.0" > .env
PORT=5050 app.jar
will then output http://0.0.0.0:5050
Integration with Guice
<dependency>
<groupId>com.github.shyiko.dotenv</groupId>
<artifactId>dotenv-guice</artifactId>
<version>0.1.1</version>
</dependency>
(Main.java)
static class S {
private final String scheme;
private final String host;
private final int port;
@Inject
public S(
@DotEnvValue("SCHEME") String scheme,
@DotEnvValue("HOST") String host,
@DotEnvValue("PORT") int port
) {
this.scheme = scheme;
this.host = host;
this.port = port;
}
public void run() {
System.out.println(scheme + "://" + host + ":" + port);
}
}
public static void main(String[] args) {
Injector injector = Guice.createInjector(new DotEnvModule()/*, ... */);
S s = injector.getInstance(S.class);
s.run();
}
Integration with Spring
(Main.java)
static class S {
private final String scheme;
private final String host;
private final int port;
@Autowired
public S(
@Value("${SCHEME}") String scheme,
@Value("${HOST}") String host,
@Value("${PORT}") int port
) {
this.scheme = scheme;
this.host = host;
this.port = port;
}
public void run() {
System.out.println(scheme + "://" + host + ":" + port);
}
}
public static void main(String[] args) {
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.getEnvironment().getPropertySources().addFirst(
new MapPropertySource("dotenv", new HashMap<>(DotEnv.load()))
);
ctx.refresh();
S s = ctx.getBeanFactory().createBean(S.class);
s.run();
}
Development
git clone https://github.com/shyiko/dotenv && cd dotenv
./mvnw # shows how to build, test, etc. project
Legal
All code, unless specified otherwise, is licensed under the MIT license.
Copyright (c) 2017 Stanley Shyiko.
*Note that all licence references and agreements mentioned in the dotenv README section above
are relevant to that project's source code only.