Oracle itself has defined certain conventions to avoid conflicts between Java classes of different programmers / companies / projects.
It suggests that a company (or any programmer) uses its own inverted web domain as the name of its packages (since the domain is unique). Example: My company owns the domain
www.empresaficticia.com.br . The main package of my projects would be defined as follows:
For cases where the web domain is not a valid package name (has hyphen, periods, starts with digits, etc.), Oracle suggests using underscore
_ . Example: my domain is
www.empresa-ficticia.com.br , so my package would be:
In addition to this top-level organization suggested by Oracle, the rest basically becomes the opinion and preference of each programmer / company. One tip for when your project gets too big is to separate it into modules that deal with only one category of features. Example: you have X classes in your project that deal only with database access, then put them in a
and another subpackage could be called
package br.com.empresa_ficticia.fs; and would contain its classes that deal with operating system files.
And a final tip, take a look at large open source projects. Analyze how they are organized. Some java projects I have already contacted and recommend to get a better idea of the subject: Apache Hadoop , Apache Giraph and Apache Hama .
But before you go out creating packages with names that have 40 characters, an invocation spell and the blood of a virgin, check if this is really necessary. If you are just doing a pet project, it will hardly be necessary to encapsulate your project in a package.