I need to have one lib-project (myLib), and several apps projects that should use source from myLib. I have troubles with configuring Eclipse.
Desired projects tree is something like that:
myProject
/src
..some files..
/bin
myLib
/src
..some files..
/bin
Now i am trying to configure myProject‘s classpath, to make it use source from myLib/src.
If i add link source using Eclipse’s GUI (UPD: I added link to the source folder this way: right-click on the project -> Build path -> Configure build path -> go to “Source” tab -> press button “Link Source…” -> specify path to the myLib/src and folder name: “lib_src“), then i got absolute path to myLib/src, i.e. the following:
myProject/.classpath:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="lib_src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
myProject/.project:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>data_manager__gui</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>lib_src</name>
<type>2</type>
<location>/HERE/IS/FULL/PATH/TO/myLib/src</location>
</link>
</linkedResources>
</projectDescription>
As I already said, I need to avoid absolute paths. So, I need path myLib/src to be specified like that: ../myLib/src
Then i tried to specify path to myLib/src manually, but if I add in .classpath the line like that:
<classpathentry kind="src" path="../myLib/src"/>
Then Eclipse thinks that .classpath is totally broken, and reset it to the following blank default:
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="output" path="bin"/>
</classpath>
Then I tried to change path in the .project file, but it seems like relative paths are totally not supported in .project file: Eclipse can’t find my myLib/src, I tried many variants.
How to achieve this?
I am not sure how you added the project reference, but in my case, the path is relative.
This is the
.classpathof a project calledAdarshwhich references another Java project calledraroscope.You should be right-clicking on your project
myProject, select Java Build Path > Projects and addmyLib(raroscopehere) as is shown below.