Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How can I cause a Java Build Path Library to resolve a new Jar added Programatically?
How can I cause a Java Build Path Library to resolve a new Jar added Programatically? [message #243323] Tue, 01 May 2007 17:58 Go to next message
John Kenny is currently offline John KennyFriend
Messages: 62
Registered: July 2009
Member
My Eclipse plugin has a builder which adds a jar file to a Project with
the Java Nature. The Java Project has a Java Build Path Library entry
for a lib folder in the project so that I can add jars to the lib dir
and not have to manually add them individually to the java build path.

When I manually add a jar file to the lib directory of the Java Project,
the Java Build Path Library entry in the properties view shows the new
jar and I can reference classes inside the jar - no problem.

When my builder adds a jar file to the lib directory of the Java
Project, the Java Build Path Library entry is not updated and the jar
does not show up - so I have compilation problems because the classes
inside that jar are not found. Any user action to the lib dir (like
touching the lib dir or adding anohter jar, etc.) will cause the Java
Build Path Library entry to update and the compilation problems are
resolved.

My guess is that when I add a jar to a Java Project via my Eclipse
Builder, some sort of notification mechanism is being skipped which
would normally cause the Java Project to see the new jar in the lib dir
and add it to the classpath.

Does anyone know how I can manually "kick" the Java Build path to see
the jar I added to the lib dir so it gets added to the classpath?
Re: How can I cause a Java Build Path Library to resolve a new Jar added Programatically? [message #243337 is a reply to message #243323] Tue, 01 May 2007 20:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"jkenny" <jkenny3112000@yahoo.com> wrote in message
news:f17v3d$qdt$1@build.eclipse.org...
> My Eclipse plugin has a builder which adds a jar file to a Project with
> the Java Nature. The Java Project has a Java Build Path Library entry for
> a lib folder in the project so that I can add jars to the lib dir and not
> have to manually add them individually to the java build path.
>
> [...]
>
> Does anyone know how I can manually "kick" the Java Build path to see the
> jar I added to the lib dir so it gets added to the classpath?

Yes, you're going to have problems whenever you try to modify a project's
inputs from within the build. Adding a jar file to the classpath within the
context of a build is sort of like in-flight refueling, a tricky
proposition.

You'd be better off if you can avoid it altogether; perhaps you can use a
ResourceChangeListener, or perhaps do it within a custom project creation
wizard, rather than trying to do it on the fly.

If you must do it on the fly, you might want to think about adding a
ClasspathContainer, with dynamic contents. But I'll caution you that that's
the approach taken by some of the WTP components and it has been problematic
because of issues with classpath containers not being fully resolved in
time.
Re: How can I cause a Java Build Path Library to resolve a new Jar added Programatically? [message #243414 is a reply to message #243323] Thu, 03 May 2007 16:17 Go to previous message
Jerome Lanneluc is currently offline Jerome LannelucFriend
Messages: 572
Registered: July 2009
Senior Member
jkenny wrote:
> My Eclipse plugin has a builder which adds a jar file to a Project with
> the Java Nature. The Java Project has a Java Build Path Library entry
> for a lib folder in the project so that I can add jars to the lib dir
> and not have to manually add them individually to the java build path.
>
> When I manually add a jar file to the lib directory of the Java Project,
> the Java Build Path Library entry in the properties view shows the new
> jar and I can reference classes inside the jar - no problem.
>
> When my builder adds a jar file to the lib directory of the Java
> Project, the Java Build Path Library entry is not updated and the jar
> does not show up - so I have compilation problems because the classes
> inside that jar are not found. Any user action to the lib dir (like
> touching the lib dir or adding anohter jar, etc.) will cause the Java
> Build Path Library entry to update and the compilation problems are
> resolved.
>
> My guess is that when I add a jar to a Java Project via my Eclipse
> Builder, some sort of notification mechanism is being skipped which
> would normally cause the Java Project to see the new jar in the lib dir
> and add it to the classpath.
>
> Does anyone know how I can manually "kick" the Java Build path to see
> the jar I added to the lib dir so it gets added to the classpath?
Since you entered a bug, let's continue the discussion there:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=184965
Previous Topic:debugger VERY slow
Next Topic:Creating project from existing source!
Goto Forum:
  


Current Time: Wed Jul 17 14:07:50 GMT 2024

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

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

Back to the top