One thing is the division into projects done by IDEs such as Eclipse and Netbeans and another thing is the division of Java into libraries.
A Java program dynamically loads classes and resources that are available in classpath
, which can be set as a parameter and consists of a list of directories and Jar files. Jar is basically a zip with compiled classes inside. So basically you can plug any dependency putting classes or jars into some directory included in classpath
.
As for the development organization, you can usually create projects of various types in IDEs: libraries and desktop (jar), web (war), enterprise with EJB (ear) programs. To define which projects depend on which, each IDE has its mechanisms, but note that this is just a logical configuration for the compilation, because as already described above, in practice, all classes see all.
Update
As mentioned in the comments, there are build tools like Maven that allow you to configure the different projects, their dependencies, the artifacts generated, the whole generation cycle.
It is a more generic and agnostic way of organizing projects. I strongly recommend it because it also facilitates integration into Continuous Integration tools, static code analysis, code generators, etc.
However, this is still not something intrinsic to Java, but a logical organization of projects.