JavaCore Classpath Entries: How to use project-relative paths? [message #261130] |
Fri, 10 July 2009 11:40  |
Eclipse User |
|
|
|
Hi,
I am trying to programmatically construct a project's classpath, adding
some jar files, that are located in a directory within the project
itself. I have this implemented and it is working, but there is one
unfortunate snag that I fail to see a way around: The static methods in
JavaCore that create classpath entries require the path to the JAR file
to be absolute or will throw an exception otherwise. As this is done for
projects that are shared via SVN, this is a problem, as the absolute
paths will have to be different on every developer's machine.
Of course, I could circumvent them and call the appropriate constructors
directly, but I'm assuming the test is there for a reason. At the same
time, I see the JDT uses project-relative paths all the time. Is there a
safe way to do so from my own code as well?
Many thanks,
Steffen
|
|
|
Re: JavaCore Classpath Entries: How to use project-relative paths? [message #261138 is a reply to message #261130] |
Sat, 11 July 2009 00:36   |
Eclipse User |
|
|
|
"Steffen Zschaler" <szschaler@acm.org> wrote in message
news:h37nd6$80v$1@build.eclipse.org...
> Hi,
>
> I am trying to programmatically construct a project's classpath, adding
> some jar files, that are located in a directory within the project itself.
> I have this implemented and it is working, but there is one unfortunate
> snag that I fail to see a way around: The static methods in JavaCore that
> create classpath entries require the path to the JAR file to be absolute
> or will throw an exception otherwise. As this is done for projects that
> are shared via SVN, this is a problem, as the absolute paths will have to
> be different on every developer's machine.
>
> Of course, I could circumvent them and call the appropriate constructors
> directly, but I'm assuming the test is there for a reason. At the same
> time, I see the JDT uses project-relative paths all the time. Is there a
> safe way to do so from my own code as well?
Take a look at JavaCore.newLibraryEntry(), and in particular see the
examples in the javadoc. Don't be fooled by the term "absolute classpath" -
this includes project-relative classpaths, confusingly.
|
|
|
Re: JavaCore Classpath Entries: How to use project-relative paths? [message #261149 is a reply to message #261138] |
Mon, 13 July 2009 05:34  |
Eclipse User |
|
|
|
Hi Walter,
Many thanks for this pointer. Stupid me, I never read far enough in the
JavaDoc (only read the JavaDoc of the method I was using directly,
should have studied the one with the most generic parameter set). Well,
thanks for making me read on!
Steffen
Walter Harley wrote:
> "Steffen Zschaler" <szschaler@acm.org> wrote in message
> news:h37nd6$80v$1@build.eclipse.org...
>
>> Hi,
>>
>> I am trying to programmatically construct a project's classpath, adding
>> some jar files, that are located in a directory within the project itself.
>> I have this implemented and it is working, but there is one unfortunate
>> snag that I fail to see a way around: The static methods in JavaCore that
>> create classpath entries require the path to the JAR file to be absolute
>> or will throw an exception otherwise. As this is done for projects that
>> are shared via SVN, this is a problem, as the absolute paths will have to
>> be different on every developer's machine.
>>
>> Of course, I could circumvent them and call the appropriate constructors
>> directly, but I'm assuming the test is there for a reason. At the same
>> time, I see the JDT uses project-relative paths all the time. Is there a
>> safe way to do so from my own code as well?
>>
>
> Take a look at JavaCore.newLibraryEntry(), and in particular see the
> examples in the javadoc. Don't be fooled by the term "absolute classpath" -
> this includes project-relative classpaths, confusingly.
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.06137 seconds