https://github.com/harium/dotenv
An utility tool to handle .env files in pure Java
https://github.com/harium/dotenv
dotenv java web
Last synced: 8 months ago
JSON representation
An utility tool to handle .env files in pure Java
- Host: GitHub
- URL: https://github.com/harium/dotenv
- Owner: Harium
- License: apache-2.0
- Created: 2015-11-20T00:08:51.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-04-16T08:02:18.000Z (about 4 years ago)
- Last Synced: 2025-07-19T03:53:08.365Z (11 months ago)
- Topics: dotenv, java, web
- Language: Java
- Homepage:
- Size: 29.3 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dotenv
[](https://circleci.com/gh/Harium/dotenv)
[](https://maven-badges.herokuapp.com/maven-central/com.harium/dotenv/)
An utility tool to handle .env files in Java.
## Maven
```
com.harium
dotenv
1.0.7
```
## Example
Create a .env file and place it at the root folder of your project.
Get your variables using:
```java
String myValue = Env.get("MY_SECRET");
```
Alternatively, you can use a custom path using the path parameter:
```java
String myValue = Env.path("/home/user/myFolder").get("MY_SECRET");
```
## Fallback
If your variable is not declared in .env, dotenv will try to load it from the environment variables.
## How it works
Dotenv looks for a .env file and loads it's contents. When you call
`Env.get("MY_SECRET");` for the first time, dotenv will try to load all the variables and cache them.
At this repo you can find an example (.env) file: [example](https://github.com/Harium/dotenv/blob/master/.env).
## License
Apache License 2.0