Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested Folders in Eclipse Classpath

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"/>

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"/>

to the classpath, it says

Cannot nest 'A/B inside library A'

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?

like image 380
Ryan Thames Avatar asked Dec 05 '08 18:12

Ryan Thames


People also ask

What is project classpath in eclipse?

The . classpath maintains the project's source and target references for Java compilation and compressed file or project dependencies. This configuration is maintained through the Java Build Path page in the project's properties.


2 Answers

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

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

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

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.

like image 83
Uri Avatar answered Sep 22 '22 20:09

Uri


Try to do this, works for me on eclipse Indigo.

<classpathentry kind="lib" path="/A" excluding="B/"/>
like image 25
michaelliu Avatar answered Sep 26 '22 20:09

michaelliu