Eclipse 在 Java Build Path -> Libraries 编辑期间不显示 lib 目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5772330/
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
Eclipse does not show lib directory during Java Build Path -> Libraries editing
提问by Robert Oschler
I have an Eclipse/Java project (Eclipse 3.5.2) that I am trying to add some JARs to. In the root project directory I have 3 sub-directories, src, bin, and liband all 3 sub-directories are present in the Package Explorer list. I put the needed JARs into lib. However, when I go to Project Propertes -> Java Build Path -> Libraries (tab) -> Add JARs, and the file dialog comes up, it only shows the srcand bindirectories in the file picker, not the libdirectory. I'm guessing it is something really simple, but can someone tell me why the file picker dialog doesn't show the libdirectory?
我有一个 Eclipse/Java 项目 (Eclipse 3.5.2),我正在尝试向其中添加一些 JAR。在根项目目录中,我有 3 个子目录,src、bin和lib并且所有 3 个子目录都存在于 Package Explorer 列表中。我将所需的 JAR 放入lib 中。但是,当我转到Project Propertes -> Java Build Path -> Libraries (tab) -> Add JARs并且出现文件对话框时,它只显示文件选择器中的src和bin目录,而不是lib目录。我猜这很简单,但有人能告诉我为什么文件选择器对话框不显示lib目录吗?
-- roschler
——罗施勒
回答by Yoni
After you copy a jar file to your lib folder, you need to refresh the project in Eclipse (use F5) so Eclipse knows about it.
将 jar 文件复制到 lib 文件夹后,您需要在 Eclipse 中刷新项目(使用 F5),以便 Eclipse 知道它。
It will then show you the lib folder in that dialog.
然后它会在该对话框中向您显示 lib 文件夹。
Note: You are correct in your answer that the said dialog doesn't reread the directory structure, but you are missing the point - it is not supposed to. That's what you have "add external jar" for. Further more, Eclipse is trying to be smart and not show you jars that you have already added (think about a folder with 50 jars and you just want to add one). That's why it didn't show you the lib folder - it thought the folder was empty.
注意:您的回答是正确的,即上述对话框不会重新读取目录结构,但您没有抓住重点 - 它不应该这样做。这就是您“添加外部罐子”的目的。此外,Eclipse 正试图变得聪明,而不是向您显示您已经添加的 jar(考虑一个包含 50 个 jar 的文件夹,而您只想添加一个)。这就是为什么它没有向您显示 lib 文件夹的原因——它认为该文件夹是空的。
回答by Robert Oschler
This is to help others. I had to do File -> Refreshto get Eclipse to see the files. Apparently file picker dialogs do not reread the disk structure. I guess they are pulling from Eclipse's main file directory image which has to be refreshed before new files are visible anywhere else in the program.
这是为了帮助他人。我必须执行File -> Refresh才能让 Eclipse 查看文件。显然文件选择器对话框不会重新读取磁盘结构。我猜他们是从 Eclipse 的主文件目录图像中提取的,该图像必须在新文件在程序中的其他任何地方可见之前刷新。
回答by Janaka Pushpakumara
This is how I resolved this problem. I created a lib folder in my java project.Then I added some jar to lib folder.
这就是我解决这个问题的方法。我在我的 java 项目中创建了一个 lib 文件夹。然后我在 lib 文件夹中添加了一些 jar。
But it doesn't appear in my eclipse IDE.Then I selected my project and right clicked on it. Then refreshed.
但是它没有出现在我的 Eclipse IDE 中。然后我选择了我的项目并右键单击它。然后神清气爽。
It works for me. I think this will help you.
这个对我有用。我想这会对你有所帮助。