I want to set the path and the attribute's value of <classpathentry>
element in .classpath
file of an existing java project.
i.e. I have an eclipse plugin that need this path, and I want to fix it if the existing path is incorrect.
for example, I want to replace the element:
<classpathentry kind="lib" path="C:/foo.jar">
<attributes>
<attribute name="javadoc_location" value="file:C:\Javadoc\"/>
</attributes>
</classpathentry>
with the element:
<classpathentry kind="lib" path="C:/ProgramsFiles/foo.jar">
<attributes>
<attribute name="javadoc_location" value="file:C:\ProgramsFiles\Javadoc\"/>
</attributes>
</classpathentry>
For now I'm using with the following code to found the entry path:
IJavaProject jProj = (IJavaProject) _Nature.getProject().getNature(JavaCore.NATURE_ID);
IClasspathEntry[] existingEntries = jProj.getRawClasspath();
// iterate over the class path
for (IClasspathEntry entry : existingEntries)
{
String entryStr = entry.getPath().toString();
....
}
how can I replace the existing path in the .classpath file?