devxlogo

Java Directory Guidelines

Java Directory Guidelines

Question:
Are there any guidelines for what the directory structure of a Java-based project should be?

Answer:
The only real guidelines govern the layout of your source code. Yourdirectories should mirror the names of your packages. For example,the source code for the classes in package com.mydomain.mypackageshould be placed in com/mydomain/mypackage.

A practice that wascommon at one time was to eliminate com/mydomain and just makesymbolic links to the current directory (e.g., ln -s . com;ln -s . mydomain). However, this only worked on Unix systems and madeit inconvenient to distribute source code for use on other platforms.Therefore the practice is discouraged.

Other directory layout issuesdepend on your specific build environment (e.g., whether you usea Makefile or an IDE-specific project file).

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist