views:

51

answers:

1

When I try to add a new Classpath Variable in Eclipse for my Build Path configuration, and the path I add is a directory that the current workspace is a subdirectory of, Eclipse gives the error:

'C:\JavaStuff' is not a valid location for linked resources.

Why does Eclipse impose this restriction? I can't think of a good reason for it... I might want to put my JARs in C:\JavaStuff\libs and have my workspace in C:\JavaStuff\workspace, then reference libs (on my machine) via JAVASTUFF_DIR\libs where JAVASTUFF_DIR is C:\JavaStuff. This restriction prevents me doing this.

A: 

OK, the reason I was having this problem was not the Classpath Variable... it was the fact that I was trying to add it to the Java Build Path, because the way I was creating the variable was to go to the Java Build Path and click 'Add Variable'. After creating the variable pointing to the directory above my workspace, I OK'd out of that dialog and it tried to add that parent dir to my build path.

Looks like the way Eclipse wants you do add JARs via Classpath Variables is 'Add Variable', select the variable representing your base path, OK back up to the Java Build Path window, then edit the entry that's been added and manually add the rest of the path on (ie. turn MY_BASE_DIR to MY_BASE_DIR/libs/library.jar. A little bit unintuative.

Jez