You could follow maven's standard project layout. You don't have to actually use maven, but it would make the transition easier in the future (if necessary). Plus, other developers will be used to seeing that layout, since many open source projects are layed out this way,

Answer from johnstok on Stack Overflow
Top answer
1 of 7
124

You could follow maven's standard project layout. You don't have to actually use maven, but it would make the transition easier in the future (if necessary). Plus, other developers will be used to seeing that layout, since many open source projects are layed out this way,

2 of 7
65

There are a few existing resources you might check:

  1. Properly Package Your Java Classes
  2. Spring 2.5 Architecture
  3. Java Tutorial - Naming a Package
  4. SUN Naming Conventions

For what it's worth, my own personal guidelines that I tend to use are as follows:

  1. Start with reverse domain, e.g. "com.mycompany".
  2. Use product name, e.g. "myproduct". In some cases I tend to have common packages that do not belong to a particular product. These would end up categorized according to the functionality of these common classes, e.g. "io", "util", "ui", etc.
  3. After this it becomes more free-form. Usually I group according to project, area of functionality, deployment, etc. For example I might have "project1", "project2", "ui", "client", etc.

A couple of other points:

  1. It's quite common in projects I've worked on for package names to flow from the design documentation. Usually products are separated into areas of functionality or purpose already.
  2. Don't stress too much about pushing common functionality into higher packages right away. Wait for there to be a need across projects, products, etc., and then refactor.
  3. Watch inter-package dependencies. They're not all bad, but it can signify tight coupling between what might be separate units. There are tools that can help you keep track of this.
🌐
DEV Community
dev.to β€Ί imajenasyon β€Ί folder-structure-backend-java-2402
Folder structure - backend java - DEV Community
April 8, 2025 - Conclusion: This folder structure for your backend project is designed to follow good software engineering practices and is highly scalable. It separates concerns into clearly defined layers (controller, service, repository) and uses standard Spring Boot project conventions. You can modify this structure to fit the specifics of your project as it evolves, but this should give you a great foundation for starting your backend application. ... Helpful guide on organizing backend Java projects!
Discussions

what's with a Java project folder structure ?

It depends on the build system in use for the project.

In the days of Ant or if you let the IDE set it up for you without specifying a build, it was mostly:

src/
bin/

Maven and Gradle use the Maven Standard Directory Layout ( https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html )

src
  main
    {lang}
      packages
    resources
  test
    {lang}
      packages
    resources

You can see that when using Gradle for groovy - https://docs.gradle.org/current/userguide/groovy_plugin.html#sec:groovy_project_layout the lang for the groovy sources is 'groovy'. This is important if you mix groovy, scala, kotlin, and java all in one project. For example (not my project, just one I found out there) https://github.com/bellingard/sample_multi-language-project

More on reddit.com
🌐 r/javahelp
9
8
September 22, 2018
project structure - Folder-by-type or Folder-by-feature - Software Engineering Stack Exchange
Within this guide there is a style ... the best approach (in this example for Java) Let's say I have an application where I can retrieve Users & Pets, using services, controllers, repositories and ofcourse domain objects. Taking the folder-by-..... styles, we have two options for our packaging structure... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
December 21, 2016
deployment - What is the project directory structure for a standalone Java SE application? - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... What is the standard project directory structure of a standalone Java SE (Command Line based) application? src folder will contain all my .java files in properly organized packages. More on stackoverflow.com
🌐 stackoverflow.com
Java : Difference between folder and package
Karrtik Iyer is having issues with: I am undergoing java web development tract and I often get confused when I hear that frameworks sometimes need our code to be in particular dire... More on teamtreehouse.com
🌐 teamtreehouse.com
2
July 22, 2016
🌐
Medium
medium.com β€Ί @zknill β€Ί how-to-structure-a-java-codebase-bcbb42f40f86
How to structure a Java codebase. Best practice for Java codebases | by Zak Knill | Medium
December 5, 2022 - In these examples, the domains are Banking, E-commerce, and Food delivery. You should structure your java code base by your domain.
🌐
Reddit
reddit.com β€Ί r/javahelp β€Ί what's with a java project folder structure ?
r/javahelp on Reddit: what's with a Java project folder structure ?
September 22, 2018 -

So here the thing guys. I'm a data engineer by profession meaning ETL/SQL master. Recently with the explosion of new tools that hit the market in big data, I'm trying to learn Java. The challenge is, wrapping my head around Java folder structure. When I look at code in GitHub for few of the Apache projects like spark/airflow, it's so convoluted and varies by developer. Is there a rule or strategy that's developers commonly follow?

Top answer
1 of 3
113

Folder-by-type only works on small-scale projects. Folder-by-feature is superior in the majority of cases.

Folder-by-type is ok when you only have a small number of files (under 10 per type, let's say). As soon as you get multiple components in your project, all with multiple files of the same type, it gets very hard to find the actual file you are looking for.

Therefore, folder-by-feature is better due to its scalability. However, if you use folder-by-feature, you end up losing information about the type of component a file represents (because it's no longer in a controller folder, let's say), so this too becomes confusing. There are 2 simple solutions for this.

First, you can abide by common naming conventions that imply its type in the file name. For example, John Papa's popular AngularJS style guide has the following:

Naming Guidelines

  • Use consistent names for all components following a pattern that describes the component's feature then (optionally) its type. My recommended pattern is feature.type.js. There are 2 names for most assets:

    • the file name (avengers.controller.js)
    • the registered component name with Angular (AvengersController)

Second, you can combine folder-by-type and folder-by-feature styles into folder-by-feature-by-type:

com.example
β”œβ”€β”€ pet
|   β”œβ”€β”€ Controllers
β”‚   |   β”œβ”€β”€ PetController1.java
|   |   └── PetController2.java
|   └── Services
β”‚       β”œβ”€β”€ PetService1.java
β”‚       └── PetService2.java
β”œβ”€β”€ user
|   β”œβ”€β”€ Controllers
β”‚   |   β”œβ”€β”€ UserController1.java
β”‚   |   └── UserController2.java
|   └── Services
β”‚       β”œβ”€β”€ UserService1.java
β”‚       └── UserService2.java
2 of 3
39

This really has nothing to do with the technology in question, unless you use a framework that forces folder-by-type on you as part of a convention-over-configuration approach.

Personally, I am strongly of the opinion, that folder-by-feature is far superior and should be used everywhere as much as possible. It groups together classes that actually work together, whereas folder-by-type just duplicates something that is usually already present in the class name.

🌐
Coderanch
coderanch.com β€Ί t β€Ί 665795 β€Ί java β€Ί practice-project-directory-structure-java
Best practice for project directory structure in java (Java in General forum at Coderanch)
May 18, 2016 - For instance, if you have a package that deals with persistence, let's say tld.company.project.repo, then I would put my DB configuration in a file src/main/config/tld/company/project/repo/db.properties, and add src/main/config as one of my project's resource folders. Whatever you do, be consistent. ... Maven separates these two: src/main/java src/test/java You don't want your release package to include your tests.
Find elsewhere
🌐
Reintech
reintech.io β€Ί blog β€Ί java-project-structure-organizing-managing-large-projects
Java project structure: Organizing and managing large projects | Reintech media
January 29, 2026 - Maven's strength lies in its opinionated project structure. When every Maven project follows the same layout, developers can navigate unfamiliar codebases immediately without hunting for source files or test directories. my-app/ β”œβ”€β”€ pom.xml β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ main/ β”‚ β”‚ β”œβ”€β”€ java/ # Application source code β”‚ β”‚ β”‚ └── com/ β”‚ β”‚ β”‚ └── mycompany/ β”‚ β”‚ β”‚ β”œβ”€β”€ domain/ β”‚ β”‚ β”‚ β”œβ”€β”€ repository/ β”‚ β”‚ β”‚ β”œβ”€β”€ service/ β”‚ β”‚ β”‚ └── controller/ β”‚ β”‚ β”œβ”€β”€ resources/ # Configuration files, properties β”‚ β”‚ β”‚ β”œβ”€
🌐
JetBrains
jetbrains.com β€Ί guide β€Ί java β€Ί tutorials β€Ί marco-codes-spring-boot β€Ί recommended-project-structure
Recommended Project Structure - Java
February 17, 2023 - What the recommended project structure for a Spring Boot project looks like Β· Recommended Java Packages Β· Downloading Images Β·
🌐
Apache Maven
maven.apache.org β€Ί guides β€Ί introduction β€Ί introduction-to-the-standard-directory-layout.html
Introduction to the Standard Directory Layout – Maven
Within artifact producing source directories (ie. main and test), there is one directory for the language java (under which the normal package hierarchy exists), and one for resources (the structure which is copied to the target classpath given the default resource definition).
🌐
Oracle
docs.oracle.com β€Ί javaee β€Ί 7 β€Ί tutorial β€Ί usingexamples006.htm
2.6 Tutorial Example Directory Structure - Java Platform, Enterprise Edition: The Java EE Tutorial (Release 7)
To facilitate iterative development and keep application source files separate from compiled files, the tutorial examples use the Maven application directory structure.
🌐
CodeSignal
codesignal.com β€Ί learn β€Ί courses β€Ί introduction-to-spring-boot-and-spring-core β€Ί lessons β€Ί understanding-project-structure
Understanding Project Structure | CodeSignal Learn
A typical Spring Boot project follows a standardized structure, especially when using Gradle as the build tool. Adhering to this structure ensures compatibility and ease of integration. Here's an outline of your project: ... src/main/java: This directory contains your main source code.
🌐
EDUCBA
educba.com β€Ί home β€Ί software development β€Ί software development tutorials β€Ί java tutorial β€Ί java project structure
Java Project Structure | How to Divide your Classes? | Importing Classes
June 19, 2023 - When creating the project structure in Java, we need to define the package name of the Java project. Java project contains multiple folders. The main folders of the Java project are config, resource, lib, and source folder.
Call Β  +917738666252
Address Β  Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
nipafx
nipafx.dev β€Ί java-react-folders
Sorting A React App Into Java's Folder Structure // nipafx
January 19, 2021 - πŸ—€ project_folder β”œβ”€ πŸ—€ node_modules β”œβ”€ πŸ—€ src β”œβ”€ πŸ—€ main β”œβ”€ πŸ—€ java └─ πŸ—€ js └─ πŸ—€ test β”œβ”€ πŸ—€ java └─ πŸ—€ js β”œβ”€ πŸ—€ target β”œβ”€ πŸ—Ž config-overrides.js β”œβ”€ πŸ—Ž package.json β”œβ”€ πŸ—Ž pom.xml └─ ...
🌐
O'Reilly
oreilly.com β€Ί library β€Ί view β€Ί java-for-dummies β€Ί 9781118239742 β€Ί a3_04_9781118239742-ch01.html
JDK Folder Structure - Java For Dummies Quick Reference [Book]
June 5, 2012 - JDK Folder Structure The JDK setup program creates several folders on your hard drive. The locations of these folders vary depending on your system, but in all versions of Windows,... - Selection from Java For Dummies Quick Reference [Book]
Author Β  Doug Lowe
Published Β  2012
Pages Β  288
🌐
Hacker News
news.ycombinator.com β€Ί item
I've never understood the intensely nested folder structure of Java apps. See: h... | Hacker News
December 14, 2011 - Or, why is the code at: Β· spring-backbone-todo/src/main/java/org/resthub/todo
🌐
Samuel Gallo
samuelgallo.com β€Ί home β€Ί optimal folder structure for java projects: best practices and guidelines
Optimal Folder Structure for Java Projects: Best Practices and Guidelines - Samuel Gallo - Full Stack Developer and IT Consultant
September 18, 2023 - Organize your classes into packages that represent different aspects of your application, such as controllers, models, services, and repositories. src/main/resources: Store non-Java resources here, such as configuration files, templates, and ...
🌐
GitHub
github.com β€Ί sombriks β€Ί how-to-structure-java-projects
GitHub - sombriks/how-to-structure-java-projects: sampling some project layouts to present in this article Β· GitHub
cd 04-managing-dependencies javac -d bin -cp bin src/Item.java javac -d bin -cp bin src/Quotes.java javac -d bin -cp bin:lib/gson-2.10.1.jar src/Grievous.java javac -d bin -cp bin src/HelloThere.java jar cvfm target/star-wars-2.jar src/META-INF/MANIFEST.MF -C bin . cp lib/gson-2.10.1.jar target/gson-2.10.1.jar java -jar target/star-wars-2.jar Β· Note that since the Class-Path is calculated from the jar location and not from the point of execution, we must moe our 3rd-party library from lib folder to target folder.
Starred by 15 users
Forked by 2 users
Languages Β  Java