Eclipse relative ClassPath question

爱⌒轻易说出口 提交于 2020-01-23 11:26:06

问题


New Eclipse user here with a quick question:

I tried changing the following line in my workspace .classpath file to solve a build error that cannot find a referenced project.

<classpathentry combineaccessrules="false" kind="src" path="/EventNotifier"/>

to

 <classpathentry combineaccessrules="false" kind="src" path="../EventNotifier"/>

After doing this, I get the following error:

Illegal entry in '.classpath' of project 'occ600server' file: Path for IClasspathEntry must be absolute

Referenced folder in not in same directory as .classpath file but one level up. How do I fix this?

TIA.


回答1:


You can use a classpath variable for this purpose.

  • Go to the workspace preferences, Java > Build Path > Classpath Variables
  • Create a new variable named WORKSPACE_ROOT (or whatever)
  • Use a <classpathentry ... /> of type var and put your variable at the start of the path attribute without any fancy ${} business.

Like so:

<classpathentry kind="var" path="WORKSPACE_ROOT/project/lib/somelibrary.jar" />

This technique is used by mvn eclipse:eclipse among other things.



来源:https://stackoverflow.com/questions/7390972/eclipse-relative-classpath-question

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