- Introduction to JVM Languages
- Vincent van der Leun
- 153字
- 2021-07-02 21:46:31
Required directory structure for class files
Class files will have to be stored in a directory structure that matches their package name. Each dot in the package name means a new subdirectory. Classes that are not put in a package are placed in the root directory that contains the initial package subdirectories.
Let's assume a project with the following fully qualified class names:
- Main
- com.example.app.model.MyModel
- com.example.app.view.MyView
- com.example.app.controller.MyController
When compiled, the directory structure should look like this:

Avoid having classes in your project that are not inside a package. In the preceding example, the Main class should ideally have been put in a package.
It must be noted that the compiler usually creates the correct directory structure in order to better understand the ClassPath topic. It is important to be familiar with the requirements described here. Also, note that some compilers, including Java, require that the source code is organized in the same way.