Java package in package?

Firstly, you should select hierarchical representation.

Secondly, you should entitle completely package name. For example, you have 'main' package and you will create 'sub' package, you should entitle this with 'main.sub'. If you have just 1 package in package, may be you can't see hierarchicaly these packages.

enter image description here

After that, package view:

enter image description here

Second sub package creation:

enter image description here

Finally package view:

enter image description here


There is no concept of package with in package. Each package is separate namespace. I think if you go to folder view instead of package view, there you may see one under another.


The eclipse package explorer has two view options: flat or hierarchical. You are probably in the flat view (which is the default, who knows why). Change the view to hierarchical by clicking on the small triangle on the top right corner of the package view and then changing the package representation.


In reality there is no such thing as a sub-package in Java - each package is a completely separate entity, with the names being seemingly hierarchical only for convenience. For example, items with default visibility are not visible in sub-packages, despite what one might expect.

If your problem has more to do with presentation and aesthetics than substance, then perhaps what you are looking for is the hierarchical package presentation setting in the Eclipse Package Explorer: click on the little downward triangle/arrow at the top right of the package explorer and select "Hierarchical" in the "Package presentation" submenu:

enter image description here

This is a global setting and will affect all your opened/un-opened projects.