Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Packaging 3rd party jars as plug-ins
Packaging 3rd party jars as plug-ins [message #336155] Wed, 27 May 2009 13:31 Go to next message
Kap Pak is currently offline Kap PakFriend
Messages: 52
Registered: July 2009
Member
Hello Guys,

I am very very sorry if here is the wrong place to post this question,
else show me the right place to post it.

I am new in Eclipse plugin development. I have develop a plugin and my
plugin requires other .jar files to work.

I have read that plugins can only use .jar files in other plugins. For
that reason i searched the web and read the following articles from these
sites:

http://www.eclipsezone.com/eclipse/forums/t54726.html

http://eclipsewiki.editme.com/PDEFaq
(The third sub-heading: How do I add a third-party JAR to a plugin
classpath?)

I have tried both ways but it seems it is still not working.

This is how i did it:

1)
I have my original project in the workspace with name "com.proj.company"

2)
I created another project with name "tryxml" according to what the links
above suggests

3)
I go to the "Dependencies" tab of my original project (com.proj.comp) and
add the "tryxml" project to the required plug-ins.

4)
After that in the same tab, i go to the imported packages part and click
on the "add..." button but i can't see the .jar files(the .jar files i
created plugin from in the "tryxml" project) in the list, to be able to
add them to the imported packages.


I don't really know what am doing wrong here.


Can someone help me to give me a step by step way of achieving it. I need
a step by step way or a pointer to a tutorial which can give me a step by
step way of making it work.

The whole question is am developing a plugin and my plugin needs other
jar files to be able to work. So kindly tell me what to do so that after
i compile the original project and get a new instance of eclipse the
pluing will work.

Thank you very much.
Re: Packaging 3rd party jars as plug-ins [message #336156 is a reply to message #336155] Wed, 27 May 2009 14:04 Go to previous messageGo to next message
Dann Martens is currently offline Dann MartensFriend
Messages: 65
Registered: July 2009
Member
Hi George,

I think you're mixing different things up, here!

The 'Imported Packages' list area in the 'Dependencies' tabs does not
show Java archives, but Java packages. That area is particularly
relevant for OSGi applications, for which it is advocated to declare
dependencies by specifying the packages, *instead* of the actual bundles
which have these packages on their plug-in classpath.

The only way you can 'make public' the Java classes in the .jar of your
project 'tryxml' is to go to the 'Runtime' tab in the Manifest editor
belonging to your 'tryxml' project. There you can add 'Exported
Packages', i.e. the packages visible on the classpath of your 'tryxml'
plug-in, either straight from inside the plug-in, or from .jars
contained in that plug-in.

Mind you, if the 'Classpath' in the 'Runtime' tab is not specified
correctly, you'll have difficulties adding 'Exported Packages'. In
'tryxml' that 'Classpath' list area should at least contain the original
..jar (and/or . (dot) if you have classes available directly on the root
of your plug-in).

Best regards,
Dann

George Murphy wrote:
> Hello Guys,
>
> I am very very sorry if here is the wrong place to post this
> question, else show me the right place to post it.
>
> I am new in Eclipse plugin development. I have develop a plugin and my
> plugin requires other .jar files to work.
>
> I have read that plugins can only use .jar files in other plugins. For
> that reason i searched the web and read the following articles from
> these sites:
>
> http://www.eclipsezone.com/eclipse/forums/t54726.html
>
> http://eclipsewiki.editme.com/PDEFaq (The third sub-heading: How do I
> add a third-party JAR to a plugin classpath?)
>
> I have tried both ways but it seems it is still not working.
>
> This is how i did it:
>
> 1)
> I have my original project in the workspace with name "com.proj.company"
>
> 2)
> I created another project with name "tryxml" according to what the links
> above suggests
>
> 3)
> I go to the "Dependencies" tab of my original project (com.proj.comp)
> and add the "tryxml" project to the required plug-ins.
>
> 4)
> After that in the same tab, i go to the imported packages part and click
> on the "add..." button but i can't see the .jar files(the .jar files i
> created plugin from in the "tryxml" project) in the list, to be able to
> add them to the imported packages.
>
>
> I don't really know what am doing wrong here.
>
>
> Can someone help me to give me a step by step way of achieving it. I
> need a step by step way or a pointer to a tutorial which can give me a
> step by step way of making it work.
> The whole question is am developing a plugin and my plugin needs other
> jar files to be able to work. So kindly tell me what to do so that after
> i compile the original project and get a new instance of eclipse the
> pluing will work.
>
> Thank you very much.
>
exporting jars within jars [message #336157 is a reply to message #336155] Wed, 27 May 2009 14:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: faraz.fallahi.googlemail.com

Hi.
I need to export my Eclipse Java project as a jar and I want to include
the referenced libraries. Ive read that eclipse doesnt support this. But
today i found a post that says eclipse 3.5 is able to do this. if so,how
does it work. ive tried eclipse 3.5 and the steps for exporting a java
project as a jar seem to be similarto prior versions.
Does anybody know anything about this ?

greez
Re: Packaging 3rd party jars as plug-ins [message #336158 is a reply to message #336156] Wed, 27 May 2009 14:39 Go to previous messageGo to next message
Kap Pak is currently offline Kap PakFriend
Messages: 52
Registered: July 2009
Member
Thanks for your reply. Its true that am mixing different things.

I created the 'tryxml' poject using the wizard "create plugin from
existing jar files".

Wel in the classpath i have the ' "." library' but when i try to add the
original .jar files from which i created the project/plugin, i see 2
folders(META-INF and org), i don't see the .jar files from which i created
the plugin. When i navigate through the META-INF folder, i see the name of
the jar files but in a folder form and wen i add them and try to update
the classpath, i get an error that it cannot be nested in the
project/plugin.

I don't know if am doing what you are telling me.


















Dan wrote,

I think you're mixing different things up, here!

The 'Imported Packages' list area in the 'Dependencies' tabs does not show
Java archives, but Java packages. That area is particularly relevant for
OSGi applications, for which it is advocated to declare dependencies by
specifying the packages, *instead* of the actual bundles which have these
packages on their plug-in classpath.

The only way you can 'make public' the Java classes in the .jar of your
project 'tryxml' is to go to the 'Runtime' tab in the Manifest editor
belonging to your 'tryxml' project. There you can add 'Exported Packages',
i.e. the packages visible on the classpath of your 'tryxml' plug-in,
either straight from inside the plug-in, or from .jars contained in that
plug-in.

Mind you, if the 'Classpath' in the 'Runtime' tab is not specified
correctly, you'll have difficulties adding 'Exported Packages'. In
'tryxml' that 'Classpath' list area should at least contain the original
..jar (and/or . (dot) if you have classes available directly on the root
of your plug-in).

Best regards,
Dann
Re: Packaging 3rd party jars as plug-ins [message #336159 is a reply to message #336158] Wed, 27 May 2009 14:49 Go to previous messageGo to next message
Dann Martens is currently offline Dann MartensFriend
Messages: 65
Registered: July 2009
Member
Hi George,

The wizard should have configured everything properly.

Could you repeat the procedure and take special care to the settings in
the 'New Plug-in from Existing JAR Archives': there is a checkbox which
enables 'Unzip the JAR archives into the project'.

If that option is enabled, the classes will be available straight from
inside the plug-in, and in that case the classpath will need to include '.'.

If that option is disabled, which is often a good idea, the jar will be
copied into the root of the project, and the .jar will be mentioned in
the 'Classpath' list area.

Regardless of that option, the 'Exported Packages' should have been
populated with all the packages originally contained in the source .jar.

Can you check this?

Best regards,
Dann






George Murphy wrote:
>
> Thanks for your reply. Its true that am mixing different things.
> I created the 'tryxml' poject using the wizard "create plugin from
> existing jar files".
>
> Wel in the classpath i have the ' "." library' but when i try to add the
> original .jar files from which i created the project/plugin, i see 2
> folders(META-INF and org), i don't see the .jar files from which i
> created the plugin. When i navigate through the META-INF folder, i see
> the name of the jar files but in a folder form and wen i add them and
> try to update the classpath, i get an error that it cannot be nested in
> the project/plugin.
>
> I don't know if am doing what you are telling me.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Dan wrote,
>
> I think you're mixing different things up, here!
>
> The 'Imported Packages' list area in the 'Dependencies' tabs does not
> show Java archives, but Java packages. That area is particularly
> relevant for OSGi applications, for which it is advocated to declare
> dependencies by specifying the packages, *instead* of the actual bundles
> which have these packages on their plug-in classpath.
>
> The only way you can 'make public' the Java classes in the .jar of your
> project 'tryxml' is to go to the 'Runtime' tab in the Manifest editor
> belonging to your 'tryxml' project. There you can add 'Exported
> Packages', i.e. the packages visible on the classpath of your 'tryxml'
> plug-in, either straight from inside the plug-in, or from .jars
> contained in that plug-in.
>
> Mind you, if the 'Classpath' in the 'Runtime' tab is not specified
> correctly, you'll have difficulties adding 'Exported Packages'. In
> 'tryxml' that 'Classpath' list area should at least contain the original
> .jar (and/or . (dot) if you have classes available directly on the root
> of your plug-in).
>
> Best regards,
> Dann
>
>
>
Re: Packaging 3rd party jars as plug-ins [message #336160 is a reply to message #336159] Wed, 27 May 2009 15:11 Go to previous messageGo to next message
Kap Pak is currently offline Kap PakFriend
Messages: 52
Registered: July 2009
Member
Thanks aain for your reply.

I am going to repeat the steps but for the mean time i want to ask this
question. How are the manifest files of the two projects are going to work
together. After i run the applicaton and get a new instance of the
workbench, i try to open a view i have created in the original project but
it cannot locate the classes which contains the views. Does the manifest
file of the 'tryxml' plugin hide the manifest file of my main project
plugin?


Thanks



Dann wrote:

The wizard should have configured everything properly.

Could you repeat the procedure and take special care to the settings in
the 'New Plug-in from Existing JAR Archives': there is a checkbox which
enables 'Unzip the JAR archives into the project'.

If that option is enabled, the classes will be available straight from
inside the plug-in, and in that case the classpath will need to include
'.'.

If that option is disabled, which is often a good idea, the jar will be
copied into the root of the project, and the .jar will be mentioned in the
'Classpath' list area.

Regardless of that option, the 'Exported Packages' should have been
populated with all the packages originally contained in the source .jar.

Can you check this?

Best regards,
Dann
Re: Packaging 3rd party jars as plug-ins [message #336161 is a reply to message #336159] Wed, 27 May 2009 15:34 Go to previous messageGo to next message
Kap Pak is currently offline Kap PakFriend
Messages: 52
Registered: July 2009
Member
Thanks :


1)
I have repeated the steps and i see the packages in the .files in the
"Exported packages" area and also the jar files appear at the classpath
area of the "Runtime" tab.

Do i have to do anything again, may be in the "Build" tab or in another
tab.


2)
When am running the application i open the "run Cnfiguration" window and
in the plugin tab i make sure 'tryxml' plugin is also checked. After i run
it, i try to open some views which i have created in the application but i
get error that says:

"Could not create the view: Plug-in was unable to load class"

The class of the view is there in my main application but it seems the
'tryxml' manifest file hides the manifest file of the main application
which am running.

Any Help?

Thanks.


Dan wrote:

The wizard should have configured everything properly.

Could you repeat the procedure and take special care to the settings in
the 'New Plug-in from Existing JAR Archives': there is a checkbox which
enables 'Unzip the JAR archives into the project'.

If that option is enabled, the classes will be available straight from
inside the plug-in, and in that case the classpath will need to include
'.'.

If that option is disabled, which is often a good idea, the jar will be
copied into the root of the project, and the .jar will be mentioned in the
'Classpath' list area.

Regardless of that option, the 'Exported Packages' should have been
populated with all the packages originally contained in the source .jar.

Can you check this?

Best regards,
Dann
Re: Packaging 3rd party jars as plug-ins [message #336163 is a reply to message #336161] Wed, 27 May 2009 16:18 Go to previous messageGo to next message
Dann Martens is currently offline Dann MartensFriend
Messages: 65
Registered: July 2009
Member
Hi George,

> 1)
> Do i have to do anything again, may be in the "Build" tab or in another
> tab.

No. It sounds as if you got things right.

> 2)
> When am running the application i open the "run Cnfiguration" window and
> in the plugin tab i make sure 'tryxml' plugin is also checked. After i
> run it, i try to open some views which i have created in the application
> but i get error that says:
>
> "Could not create the view: Plug-in was unable to load class"
>

Well, some diagnostics are in order to get to the bottom of this.

(1) Check the state of the bundles: add '-console' to the 'Program
Arguments' text area, on the '(x)= Arguments' tab of your application's
run target. Once the test workbench is running with your plug-ins, go
back to your source workbench's 'Console' View and type 'ss' in there;
check for the state of your two plug-ins. What are those states?

(2) Check the 'Error Log' in the workbench you have started to test your
plug-ins. Either open the 'Error Log' View or use 'Help > [Configuration
Details] > [View Error Log]'. Do you see any stacktraces originating
from inside your code? Any other stacktraces?

(3) Verify the structure of your two plug-ins. The 'tryxml' is it a pure
library bundle, or have you already somehow defined extensions? I
would expect your main plug-in already does that. Where are the View
contributions declared? How and where does the View access the tryxml
library classes?

Best,
Dann
Re: Packaging 3rd party jars as plug-ins [message #336174 is a reply to message #336155] Wed, 27 May 2009 20:00 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

George Murphy wrote:
> Hello Guys,
>
> I am very very sorry if here is the wrong place to post this
> question, else show me the right place to post it.
>
> I am new in Eclipse plugin development. I have develop a plugin and my
> plugin requires other .jar files to work.
>
> I have read that plugins can only use .jar files in other plugins.

That is not really accurate. A plug-in can contain JAR files and use the
classes from that JAR; you do not have to put the JAR into a separate
plug-in (although in some circumstances that is the better design).
Here are the steps:

1) In your plug-in project, create a lib/ directory and put the JAR(s)
in it (you can call it anything you want, not just "lib").
2) Open the manifest.mf for your plug-in, go to the Runtime tab.
3) In the Classpath section, use the Add... button to select the JAR(s)
from the lib/ directory in step 1).
4) On the Build tab of the manifest editor, make sure the lib/ directory
is "checked" in the Binary Build section (this ensures that the JAR(s)
are included when you build/export your plug-in).
5) Save the manifest, which will trigger a re-build of your plug-in.

Hope this helps,
Eric
Previous Topic:navigatorContent not updating
Next Topic:ShowViewDialog to open only FastViews
Goto Forum:
  


Current Time: Fri Dec 27 04:15:50 GMT 2024

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

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

Back to the top