I would recommend to stick with default Maven layout ( and also use maven as build tool )

Productive classes / resources:

src/main/java
src/main/resources

Test data and classes:

src/test/java
src/test/resources

Maven can also take care to package your application properly with all the necessary jars ( look for maven assembly plugin )

Answer from Konstantin Pribluda on Stack Overflow
🌐
Apache Maven
maven.apache.org β€Ί guides β€Ί introduction β€Ί introduction-to-the-standard-directory-layout.html
Introduction to the Standard Directory Layout - Apache 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).
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
Java Directory Structure - Stack Overflow
Set the destination directory for class files. The destination directory must already exist; javac will not create the destination directory. If a class is part of a package, javac puts the class file in a subdirectory reflecting the package name, creating directories as needed. More on stackoverflow.com
🌐 stackoverflow.com
Java directory structure
You can do whatever the heck you want. But standardisation is there to help you, not to work against you. In your example; where are you going to put the tests for Vector3.java? More on reddit.com
🌐 r/javahelp
15
1
February 19, 2018
How to create a directory and sub directory structure with java? - Stack Overflow
Hello there I want to create the directories and sub directories with the java. My directory structure is starts from the current application directory, Means in current projects directory which lo... More on stackoverflow.com
🌐 stackoverflow.com
🌐
DEV Community
dev.to β€Ί imajenasyon β€Ί folder-structure-backend-java-2402
Folder structure - backend java - DEV Community
April 8, 2025 - 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!
🌐
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)
Java Platform, Enterprise Edition: The Java EE Tutorial Β· Previous PageNext Page Β· To facilitate iterative development and keep application source files separate from compiled files, the tutorial examples use the Maven application directory structure. Each application module has the following structure: pom.xml: Maven build file Β·
🌐
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?

Find elsewhere
Top answer
1 of 2
2

-d classes command line switch tells the compiler to store compiled code in classes folder.

See documentation of javac:

-d directory

Set the destination directory for class files. The destination directory must already exist; javac will not create the destination directory. If a class is part of a package, javac puts the class file in a subdirectory reflecting the package name, creating directories as needed. For example, if you specify -d /home/myclasses and the class is called com.mypackage.MyClass, then the class file is called /home/myclasses/com/mypackage/MyClass.class.

If -d is not specified, javac puts the class file in the same directory as the source file.

2 of 2
1

If you run javac without any arguments, help content gets printed

Usage: javac <options> <source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are used
  -classpath <path>          Specify where to find user class files and annotation processors
  -cp <path>                 Specify where to find user class files and annotation processors
  -sourcepath <path>         Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>       Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...]Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -d <directory>             Specify where to place generated class files
  -s <directory>             Specify where to place generated source files
  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
  -encoding <encoding>       Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified release
  -target <release>          Generate class files for specific VM version
  -version                   Version information
  -help                      Print a synopsis of standard options
  -Akey[=value]              Options to pass to annotation processors
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system

And -d says -d <directory> Specify where to place generated class files

🌐
Apache Ant
ant.apache.org β€Ί easyant β€Ί history β€Ί trunk β€Ί ref β€Ί Directorystructure.html
Directory structure - Apache Ant
To clarify the directory structure source files and resources are separated in two directory. The directory structure of project source code looks like : src/main/java for main source code (note that this can be configured through the property src.main.java)
🌐
IBM
ibm.com β€Ί docs β€Ί en β€Ί wm-application-platform β€Ί 10.7.0
Folder Structure of Java Projects
Build, govern, and manage your data for generative AI solutions Β· Use pre-integrated automation technologies to design, build, and run automation applications and services on the cloud
🌐
Oracle
docs.oracle.com β€Ί javase β€Ί 8 β€Ί docs β€Ί technotes β€Ί tools β€Ί windows β€Ί jdkfiles.html
3 JDK and JRE File Structure
April 21, 2026 - The PATH environment variable should contain an entry for this directory. ... Files used by the development tools. Includes tools.jar, which contains non-core classes for support of the tools and utilities in the JDK. Also includes dt.jar, the DesignTime archive of BeanInfo files that tell interactive development environments (IDEs) how to display the Java components and how to let the developer customize them for an application.
🌐
Baeldung
baeldung.com β€Ί home β€Ί maven β€Ί apache maven standard directory layout
Apache Maven Standard Directory Layout | Baeldung
January 8, 2024 - As the name indicates, src/main is the most important directory of a Maven project. Anything that is supposed to be part of an artifact, be it a jar or war, should be present here. ... src/main/resources – configuration files and others such as i18n files, per-environment configuration files, and XML configurations Β· src/main/webapp – for web applications, contains resources like JavaScript, CSS, HTML files, view templates, and images
🌐
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
07-gradle-project β”œβ”€β”€ app β”‚ β”œβ”€β”€ build.gradle β”‚ └── src β”‚ β”œβ”€β”€ main β”‚ β”‚ β”œβ”€β”€ java β”‚ β”‚ β”‚ └── sample β”‚ β”‚ β”‚ └── structure β”‚ β”‚ β”‚ └── App.java β”‚ β”‚ └── resources β”‚ └── test β”‚ β”œβ”€β”€ java β”‚ β”‚ └── sample β”‚ β”‚ └── structure β”‚ β”‚ └── AppTest.java β”‚ └── resources β”œβ”€β”€ gradle β”‚ └── wrapper β”‚ β”œβ”€β”€ gradle-wrapper.jar β”‚ └── gradle-wrapper.properties β”œβ”€β”€ gradlew β”œβ”€β”€ gradlew.bat β”œβ”€β”€ messages.json └── settings.gradle
Starred by 15 users
Forked by 2 users
Languages Β  Java
🌐
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 - src/main/resources: Store non-Java resources here, such as configuration files, templates, and static assets (e.g., CSS, JavaScript files). src/test: Keep your unit and integration tests separate from your main source code. Follow a similar package structure as your main codebase to mirror the organization. target: This is the output directory where compiled classes and packaged artifacts are generated.
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί java β€Ί java-program-to-display-all-the-directories-in-a-directory
Java Program to Display all the Directories in a Directory - GeeksforGeeks
July 23, 2025 - File organization structure is a hierarchical structure involving parent and child relationships just like what is there in tree data structures. It will vary from operating systems, rather the efficiency of the operating system is measured with the ease of file organization structure for the end-users. The following classes in Java are present there to list directory content
🌐
TechRepublic
techrepublic.com β€Ί home β€Ί developer
Directory Navigation in Java - TechRepublic
July 15, 2023 - This might affect product placement on our site, but not the content of our reviews. See our Terms of Use for details. A directory is an organizational file system structure that contains files and other directories.
🌐
JAXB
javaee.github.io β€Ί tutorial β€Ί usingexamples006.html
Tutorial Example Directory Structure
To facilitate iterative development and keep application source files separate from compiled files, the tutorial examples use the Maven application directory structure. Each application module has the following structure: pom.xml: Maven build file Β· src/main/java: Java source files for the module Β·