Eclipse gives error “… is not a valid location for linked resources.”

不打扰是莪最后的温柔 提交于 2019-12-14 01:33:55

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3298029/eclipse-gives-error-is-not-a-valid-location-for-linked-resources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!