问题
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 typevar
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