eclipse 如何在eclipse项目资源管理器中的包内创建子包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15684183/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 21:39:24  来源:igfitidea点击:

How to create a child package inside a package in eclipse project explorer

eclipsepackage

提问by user1907521

How can I make a child package inside a package in eclipse project explorer?

如何在 eclipse 项目资源管理器中的包内创建子包?

I already tried..

我已经试过了。。

com.proj.test

com.proj.test

then I create a new package

然后我创建一个新包

com.proj.test.child

com.proj.test.child

to add a child package at package

在 package 添加一个子包

com.proj.test,

com.proj.test,

but did not succeed

但没有成功

回答by Guilherme Muniz

To enable hierarchical visualization in the eclipse package explorer do these following steps:

要在 eclipse 包浏览器中启用分层可视化,请执行以下步骤:

In The Package Explorer View / View Menu (An arrow pointing down on top right) Go to Package Presentation and set type to Hierarchical.

在包资源管理器视图/视图菜单(右上角向下的箭头)中,转到包演示并将类型设置为分层。

回答by Pavel

What you did is correct, I assume you are using 'Project explorer' view, switch to hierarchical view to see content as child-parent : Window->Show View->Navigator

您所做的是正确的,我假设您使用的是“项目资源管理器”视图,切换到分层视图以将内容视为子父级:Window->Show View->Navigator

回答by Micha?l

Right click on the package com.proj.test, new-> packageand then write com.proj.test.childfor the name.

右键单击包com.proj.test新建->,然后com.proj.test.child输入名称。

I tried it just now and it works well.

我刚才试过了,效果很好。

回答by cagcak

When you select "New Package" off the eclipse menu, the corresponding folder(s) will also be created automatically.

当您从 eclipse 菜单中选择“New Package”时,也会自动创建相应的文件夹。

You don't have to define sub-packages one level at a time.

您不必一次定义一个级别的子包。

If You define a new package and enter the package name

如果您定义一个新包并输入包名称

com.coder.javapackage.innerone.etc

com.coder.javapackage.innerone.etc

any missing elements in that package tree will also be created automatically.

该包树中的任何缺失元素也将自动创建。

Example from eclipse

日食的例子

This is just visual representation on the package. In reality they can sit in two different jars, but you should not be concerned about it, because jvm and loader internally handle that.

这只是包装上的视觉表示。实际上,它们可以放在两个不同的 jar 中,但您不必担心,因为 jvm 和 loader 会在内部处理它。

回答by sudo

I gave up on trying to reason with Eclipse as it seemed to completely ignore my hierarchal package representation setting, plus it was ignoring packages for some reason and refusing to compile as a result… I just made the folder hierarchy myself in Finder then imported it into Eclipse. That fixed everything.

我放弃了对 Eclipse 进行推理的尝试,因为它似乎完全忽略了我的分层包表示设置,而且它出于某种原因忽略了包并因此拒绝编译……我只是在 Finder 中自己创建了文件夹层次结构,然后将其导入蚀。那解决了一切。

回答by Mjachowdhury

First create the parent package and then press the right click on the parent package select new package where you see new window will appear then write new package name beside the parent package with dot. Ex- test (this is parent package called test) test.model (this is child package called model) like this you can on and on to make more package like - test.model.modelOne Hope this will help someone.

首先创建父包,然后在父包上右键单击选择新包,您会看到将出现新窗口,然后在父包旁边用点写新包名称。Ex-test(这是名为 test 的父包) test.model(这是名为 model 的子包) 像这样你可以继续制作更多的包,比如 - test.model.modelOne 希望这会对某人有所帮助。

回答by Lucas Francisco

I was able to change the "Package Presentation" option, which by default has the option "Flat" to "Hierarchical". This option is present in button "View menu", on "Project Explorer" perspective.

我能够更改“ Package Presentation”选项,默认情况下将“ Flat”选项更改为“ Hierarchical”。此选项出现在“项目资源管理器”透视图上的“视图菜单”按钮中。

回答by Jasmin Guberinic

In Project Explorer perspective View Menu -> Package Presentation -> Hierarchical . I hope it helps.

在 Project Explorer 透视图中 View Menu -> Package Presentation -> Hierarchical 。我希望它有帮助。

回答by Sachindra N. Pandey

If your project under "Project explorer" view then change it to "Navigator" . As follows

如果您的项目在“项目资源管理器”视图下,则将其更改为“导航器”。如下

      Window->Show View->Navigator
      By doing this you will able to see packages as parent child hierarchy. 

回答by aeocom

Right click on package parent and write complete name of child package is OK. But then to have a good graphical representation, you have to add a filein this child package... It's just refresh IHM (if you look folders of project, they already exist before this refresh). Eclipse does not refresh enough project window...

右键单击包父级并写入子包的完整名称即可。但是为了有一个好的图形表示,你必须在这个子包中添加一个文件......它只是刷新IHM(如果你查看项目文件夹,它们在刷新之前已经存在)。Eclipse 没有刷新足够的项目窗口...