Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » JavaCore Classpath Entries: How to use project-relative paths?
JavaCore Classpath Entries: How to use project-relative paths? [message #261130] Fri, 10 July 2009 11:40 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
"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 Go to previous message
Eclipse UserFriend
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.
>
>
>
Previous Topic:IContainer for LaunchConfigurations
Next Topic:Breakpoint not working
Goto Forum:
  


Current Time: Thu May 01 10:24:48 EDT 2025

Powered by FUDForum. Page generated in 0.06137 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top