How do I make child packages in packages in Eclipse?

I recently started coding Eclipse plugins for Minecraft Bukkit and it is fine. I recently tried to create a child package to a package, but if I try Create> Package it will make a separate package for my main package. I'm a beginner, so please keep the instructions simple. Is there anything else I can try?

+3


source to share


3 answers


Usually, if you split each component of a package with dots ( .

), it should create intermediate entries.

Try creating a new package with the following test case:

  • com.foobar.example

  • com.foobar.test

  • com.foobar.example.a

And Eclipse has to do the tricks.

If, however, you get stuck looking for these empty packages, perhaps you should just play with the Package Explorer options : Java Filters are especially useful, and there may be a default option to filter / hide an empty package.



You also have package presentations.

Since an image is better than long lines of text:

Eclipse

  • Click the arrow to open the presentation options (see the package explorer on the left).
  • Filter options have filters that can hide empty parent packages.
  • The hierarchical package presentation behaves like the left Explorer pane.
+9


source


When creating a new package, you can create a hierarchy simply by dividing the parent folder with the child folder by dot '.'

. Therefore, if you want to create an additional package foo.bar

, you need to create a package named foo.bar.myfoo

. Eclipse does the rest.

If you want to render the hierachy folder type like here:



enter image description here

you can click the small arrow at the top left of the project explorer view and navigate to Package Presentation> Hierarchical .

+4


source


The folder-like hierarchy is implicitly created by package names in Java. Let's say you have a package com.company

and you want to get a subpackage in that package. Then you need to create a package named com.company.product

. It is not creating a named package product

when selected com.company

!

+2


source







All Articles