Eclipse 给出错误“...不是链接资源的有效位置。”
当我尝试在 Eclipse 中为构建路径配置添加新的类路径变量,并且我添加的路径是当前工作区是其子目录的目录时,Eclipse 会给出错误:
'C:\JavaStuff' is not a valid location for linked resources.
为什么 Eclipse 强加此限制?我想不出一个很好的理由...我可能想将我的 JAR 放在 C:\JavaStuff\libs
中,并将我的工作区放在 C:\JavaStuff\workspace< /code>,然后通过
JAVASTUFF_DIR\libs
引用库(在我的机器上),其中 JAVASTUFF_DIR
是 C:\JavaStuff
。这个限制阻止我这样做。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我遇到这个问题的原因不是类路径变量...而是我试图将其添加到 Java 构建路径,因为我创建变量的方式是转到 Java 构建路径并单击“添加变量”。创建指向工作区上方目录的变量后,我退出该对话框,并尝试将该父目录添加到我的构建路径中。
看起来 Eclipse 希望您通过类路径变量添加 JAR 的方式是“添加变量”,选择代表基本路径的变量,确定返回到 Java 构建路径窗口,然后编辑已添加的条目并手动添加其余的路径(即将
MY_BASE_DIR
到MY_BASE_DIR/libs/library.jar
。有点不直观。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
toMY_BASE_DIR/libs/library.jar
. A little bit unintuative.