Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make child packages in packages on Eclipse?

Tags:

eclipse

I have recently started coding on Eclipse for Minecraft Bukkit plugins, and I have been going fine with it. Recently, I've been trying to make a child package into a package, but if I try New > Package, then it makes a package separate to my main package. I am a beginner, so please make instructions simple. Is there anything else I can try?

like image 864
Permanently Avatar asked Aug 19 '14 08:08

Permanently


People also ask

Can we create package within a package in Eclipse?

You can add a new package in Eclipse by right-clicking on your project and selecting New > Package. Note that a package doesn't really exist until you create some class or interface in that package. The more logical way to do this is to simply define a package when creating a new class.

How do I make packages inside a package?

To create a class inside a package, declare the package name in the first statement in your program. A class can have only one package declaration. Now lets see how to use this package in another program. To use the class Calculator, I have imported the package letmecalculate .

Can you create a package inside a package in Java?

Including a Class in Java PackageTo create a class inside a package, you should declare the package name as the first statement of your program. Then include the class as part of the package. But, remember that, a class can have only one package declaration.


1 Answers

Normally, if you separate each package component with dots (.), it should create intermediate entries.

Try create a new package with the following test case:

  • com.foobar.example
  • com.foobar.test
  • com.foobar.example.a

And Eclipse should do the tricks.

If however, you are stuck with finding those empty packages, perhaps you should simply play with the Package Explorer options: the Java filters is especially useful, and there might be an option enabled by default which would filter/hide empty package.

You also have Package presentations.

Since an image is better than long lines of text:

Eclipse

  1. Click the arrow to open the presentations options (see the Package Explorer on the left)
  2. The Filters options does have filters which might hide empty parent packages.
  3. The hierarchical package presentation behave like the Explorer left pane.
like image 128
NoDataFound Avatar answered Oct 22 '22 15:10

NoDataFound