Eclipse类路径中的嵌套文件夹 [英] Nested Folders in Eclipse Classpath

查看:106
本文介绍了Eclipse类路径中的嵌套文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将两个文件夹添加到eclipse项目的类路径中,比如说文件夹A和文件夹B。B在A内。每当我将A添加到类路径中

I'm trying to add two folders to my eclipse project's classpath, let's say Folder A and Folder B. B is inside A. Whenever I add A to the classpath

<classpathentry kind="lib" path="/A"/>

它工作得很好,但是我还需要能够访问B中的文件。每当我尝试添加

it works just fine, but I need to be able to access the files in B as well. Whenever I try to add

<classpathentry kind="lib" path="/A/B"/>

到类路径,它说


无法在库A中嵌套'A / B'

Cannot nest 'A/B inside library A'

在编辑方面,我是新手我想知道,是否在classpath中添加了一个文件夹,该文件夹嵌套在eclipse classpath的另一个文件夹中?

I'm a newbie when it comes to editing the classpath, so I'm wondering, is there is anyway to add a folder in the eclipse classpath that is nested in another folder that is also in the eclipse classpath?

推荐答案

我认为您不能(或应该)这样做,但这并不是Eclipse问题AFAIK

I don't think you can (or should be) allowed to do that, and it's not really an Eclipse issue AFAIK

任何单独的类路径都是根目录,JVM在该根目录下开始使用标准软件包表示法来查找类

Any individual classpath is a root under which the JVM starts looking for classes using the standard package notation

因此,假设您的程序在默认软件包中具有类X,并且b包中的bX类。如果默认的软件包根目录是/ a,则您的软件包b将位于/ a / b

So let's say that your program has a class X in the default package, and a b.X class in the b package. If the default package root is /a, then your package b would be in /a/b

如果您有一个指向/ a的类路径根和一个指向/ a的类路径根到/ a / b,现在您请求类X,那么您可以将您的请求解释为默认包中的X(因为在A处有根),也可以解释为相对于路径/的默认包中的X类。 a / b,但这就是类bX

If you had one classpath root pointing to /a and one classpath root pointing to /a/b, and now you asked for class X, then one could interpret your request as X in the default package (since there is a root at A), but also as class X in the default package relative to the path /a/b, but that is the class b.X

因此,为防止这些情况发生,不允许嵌套嵌套类路径根。

So to prevent these things from happening, you're not allowed to have classpath roots that are nested.

这篇关于Eclipse类路径中的嵌套文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆