0

I have a package where I'm putting all of my code.

However, I would now like to create a folder\package inside of that package like a child package.

I was unable to make a child package in eclise by folllowing the convention ExistingPackagename.ChildPackagename. So I went to my file system, made the desired structure. When I refresh, I see that my file system has the structure I want, but on eclipse, it still shows the Parent and the child packages at the same level. It shows my packages in the same level as

  1. Parent
  2. Parent.Child1
  3. Parent.Child2
  4. Parent.Child3
2
  • Please clarify; what is your question? Modify a class in Child1 and change the package name to Parent.Child1. Commented Oct 1, 2015 at 1:32
  • Are your folders empty? If so, Eclipse flattens package names. Commented Oct 1, 2015 at 1:36

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

You are probably in the "Project Explorer" view. Select Window -> Show view -> Package Explorer Also, you don't have to create child packages from the file system. Just right click the current package, select New -> Package adding Package

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.