I recently started with Java and have done a few projects on it, e.g. Checked it out on GitHub. It struck me that the projects are mostly divided (which makes perfect sense). Here is an example from the Minecraft Bukkit project on GitHub:
src /
Main/
javadoc /
Java/
org /
bukkit /
block/
Beacon.java
Biome.java
…
command /
BlockCommandSender.java
…
…
BanEntry.java
…
site /
…
test / java / org / bukkit /
…
However, I still have a few questions:
Why is the actual Bukkit folder in bukkit / src / main / java / org / bukkit / and not just in bukkit / src / or bukkit / main / src /?
How would you import the project? With import java.org.bukkit ;?
What structure do you use? / Which would you recommend?
A package is usually named after the URL of the creator.
For example, my packages are called all
com.spacewar.beans
com.spacewar.server
com.spacewar.etc
or
de.xearox.server
de.xearox.etc
and if you now follow the path it says:
src / main / java / com / spacewar / server / Server.java
How do you import anything?
You add the jar to your buildpath and can then access the functions of the jar.
And for the last point, see above, that's how I do it.
This corresponds to the Maven project structure.
https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
You don't have to use it, but it is more or less the de facto standard in OSS projects because Maven is used very often there (and even if it's Gradle, it is often based on the Maven layout).
Another issue is the package structure in there. It depends on the project, but there are useful patterns - for example according to layers (e.g. Backend, frontend) and according to functional areas. Here is an example: https://blog.hello2morrow.com/2015/06/love-your-architecture/