The Java Dev Environment That Just Works¶
Setting up a Java project shouldn’t take hours, involve outdated wikis, or require tribal knowledge.
This setup gives you a development environment that works the moment you clone the repo — no guesswork, no manual installs, no surprises.
What We Want¶
- Same Java and Maven versions
- Same environment variables
- Same commands
Clone → setup → start coding
The Big Picture¶
flowchart LR
A[Clone Repo] --> B[Enter Directory]
B --> C[direnv loads .envrc]
C --> D[Environment Variables Loaded]
C --> E[SDKMAN sets Java & Maven]
D --> F[Ready to Develop]
E --> F Install the Basics¶
Install SDKMAN:
Tools¶
Environment Variables with dotenv¶
We separate config from code:
.env.shared→ team-wide config.env→ local secrets
Lock Java & Maven Versions SDKMAN¶
It ensures that every developer is using the exact same version of Maven and the JDK, which is the core of your Java work.
Automatic Environment Loading direnv¶
It watches your terminal. As soon as you cd into your project, it executes the .envrc file. This loads the devenv shell and any environment variables into your current terminal session.
Warning
Run direnv allow once after cloning.
Standard Commands with task¶
Instead of typing complex commands you just type task <cmd>.
version: '3'
tasks:
setup:
desc: Install dependencies and initialize environment
cmds:
- sdk env install
- direnv allow
clean:
desc: Clean build artifacts
cmds:
- ./mvnw clean
Run commands like:
Lefthook and EditorConfig¶
These prevent "pollution" of the codebase.
- EditorConfig tells IntelliJ or VS Code syntax.
- Lefthook acts as a final gate.
Key Files¶
| File | Purpose |
|---|---|
.sdkmanrc | Java & Maven versions |
.env | Local variables |
.env.shared | Shared variables |
.envrc | Environment automation |
Taskfile.yml | Commands |
Why This Works¶
This setup removes friction:
- No manual setup
- No version mismatches
- No hidden configuration
You spend time building, not debugging your environment.