Creating a Default Java + JUnit Project Template in IntelliJ
One of the small but persistent sources of friction when practising coding katas (or doing interview prep) is project setup.
You open IntelliJ, create a new project… and immediately have to:
create packages
create
src/test/javaadd JUnit
write a throwaway test just to get started
None of that is interesting. None of it is what you’re trying to practise.
This post shows how to set up a reusable IntelliJ project template so every new Java project starts with:
a proper package structure
a test directory
JUnit already wired up
a sample unit test ready to run
Once it’s done, you never think about it again.
Why use a project template?
IntelliJ does have some defaults, but they’re shallow:
packages are often missing
tests may or may not exist
dependencies vary depending on wizard choices
A project template gives you:
a consistent baseline
zero setup friction
fewer excuses to skip tests “just this once”
For katas especially, this matters. The exercise should be about design and code, not tooling.
Step 1: Create a “golden” starter project
Start by creating a normal project, exactly how you want all future projects to look.
File → New → Project
Choose:
Java
Your preferred build tool (Gradle or Maven)
A JDK version you commonly use
Finish the wizard.
Step 2: Create the directory and package structure
Create the standard layout:
src/
main/
java/
com.example.kata
test/
java/
com.example.kata
Make sure:
src/main/javais marked as Sources Rootsrc/test/javais marked as Test Sources Root
(IntelliJ usually does this automatically, but it’s worth checking.)
Step 3: Add JUnit
Add JUnit to your build file.
For Gradle (JUnit 5 example):
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter")
}
test {
useJUnitPlatform()
}
For Maven, add the equivalent JUnit dependency.
The exact version isn’t important — consistency is.
Step 4: Add a sample unit test
Create a minimal test class under src/test/java:
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
class ExampleTest {
@Test
void exampleTest() {
assertTrue(true);
}
}
Run it once to confirm:
JUnit is correctly configured
tests run without extra setup
This test isn’t valuable in itself. It just proves the wiring works.
Step 5: Save the project as a template
Now turn this project into something reusable.
File → Save Project as Template…
Give it a clear name, for example:
Java Kata TemplateJava + JUnit Starter
Save
That’s it.
Step 6: Use the template for new projects
Next time you create a project:
File → New → Project
Choose User-defined (or From Template, depending on IntelliJ version)
Select your saved template
Your new project will already have:
packages
test structure
JUnit
a runnable test
No setup. No friction.
Why this is worth doing
This setup supports a simple rule:
Don’t make the boring stuff part of the exercise.
When you remove setup noise:
tests get written earlier
refactoring feels safer
practice sessions start faster
It’s a small investment that pays off every time you open IntelliJ.
Final thoughts
You can keep refining this template:
add common test utilities
add a preferred package naming scheme
include a README stub
tweak Gradle or Maven defaults
But even a minimal template like this dramatically improves the experience of doing katas, experiments, or interview prep.
Once you’ve done it, you’ll wonder why you didn’t earlier.