Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Using external jar file from eclipse plugin
icon5.gif  Using external jar file from eclipse plugin [message #646624] Wed, 29 December 2010 12:12 Go to next message
daisydale85 is currently offline daisydale85Friend
Messages: 38
Registered: August 2010
Member
Hi,

I am developing an eclipse plugin which has dependency on an external jar file. Due to the license restrictions, I cannot bundle the external jar in my plugin. So is there any other way with which I can refer to the external jar? I can ask users of my plugin to copy the external jar to the eclipse plugins folder. I am getting NoClassDefFound exception while my plugin tries to access the external Jar eventhough the jar file is in the same folder as that of my plugin. I tried this by declaring a variable that points to the plugin directory. I saw lot of posts related to this but none helped me solve my problem.
Please let me know if you have any idea on this.

Thanks in advance,
Daisy.
Re: Using external jar file from eclipse plugin [message #646689 is a reply to message #646624] Thu, 30 December 2010 05:03 Go to previous messageGo to next message
manasa  is currently offline manasa Friend
Messages: 32
Registered: October 2010
Member
You could try by creating a utility project, adding the required jar to its build path, and creating a dependency from your plugin to the utiltiy project.
Hope this helps.

Regards,
Manasa
Re: Using external jar file from eclipse plugin [message #646691 is a reply to message #646689] Thu, 30 December 2010 06:08 Go to previous messageGo to next message
daisydale85 is currently offline daisydale85Friend
Messages: 38
Registered: August 2010
Member
Hi Manasa,

Thanks for the reply. I did try that method and it is working. But my issue is that I cannot distribute the external jar. So I need my plugin to refer it from the location where user puts the external jar file (in my case, it will be in the eclipse\plugins folder). Is there a way to do it?

Thanks,
Daisy.
Re: Using external jar file from eclipse plugin [message #646704 is a reply to message #646691] Thu, 30 December 2010 09:29 Go to previous messageGo to next message
daisydale85 is currently offline daisydale85Friend
Messages: 38
Registered: August 2010
Member
Today I tried the following method and it works upto an extent.

I created a "lib" folder in my project and placed my external jar file in that. Then I included this path in "Extra Class Path Entries". Now my plugin builds perfectly. After that, I gave following statement in Manifest.MF

Bundle-ClassPath: .,
 external:C:/JarLoc/externaljar.jar


Now when I deployed the plugin, it worked. But I cannot give the absolute path location. So I tried by changing the above code as follows (externaljar.jar will be in the same location as that of the eclipse plugins).

Bundle-ClassPath: .,
 external:$ECLIPSE_HOME$/plugins/externaljar.jar


But eclipse doesnt seem to understand the variable "ECLIPSE_HOME". I am not much familiar with the variable usage and hence I dont know whether I missed to do something else. Do I need to add this variable through "Configure Build-Path"? My understanding is that entries in Build Path will be used during compile time only. Hence I didnt add the variable to build path. Also do I need to explicitly load the class from code? Isnt ECLIPSE_HOME a built-in value?

I also tried by giving relative path as follows.
Bundle-ClassPath: .,
 external:..\externaljar.jar
But this also didnt work.

Please let me know if I am missing something.

Thanks,
Daisy.
Re: Using external jar file from eclipse plugin [message #646796 is a reply to message #646704] Fri, 31 December 2010 10:57 Go to previous messageGo to next message
daisydale85 is currently offline daisydale85Friend
Messages: 38
Registered: August 2010
Member
I got this working by giving the class path as following

Bundle-ClassPath: .,
 external:$osgi.syspath$\externaljar.jar


Though osgi.syspath is pointing to eclipse\plugins folder, I am not sure this system variable can be used for finding the class path.

Following will also work.

Bundle-ClassPath: .,
 external:$user.dir$\plugins\externaljar.jar


user.dir points to directory of eclipse.exe (current directory of the application). But there is a chance for this value to be set to some other value depending upon user choice. Hence I used osgi.syspath. Please let me know if this is not the correct method.

Thanks,
Daisy.
Re: Using external jar file from eclipse plugin [message #823996 is a reply to message #646796] Mon, 19 March 2012 05:55 Go to previous messageGo to next message
Sabir Mising name is currently offline Sabir Mising nameFriend
Messages: 68
Registered: February 2010
Member
Hi daisydale
I tried adding my external jar as specified by you ie., using
Bundle-ClassPath: .,
external: ${user.dir}\plugins\my_externaljar.jar

But it is not working , I am not able to see this jar as part of the classpath for my plugin nor I Can use any APIs of this jar

So can you please give more details about how to make it part of classpath entry for my plugin project
Re: Using external jar file from eclipse plugin [message #825042 is a reply to message #823996] Tue, 20 March 2012 11:43 Go to previous messageGo to next message
Sabir Mising name is currently offline Sabir Mising nameFriend
Messages: 68
Registered: February 2010
Member
Hi Daisydale

Now its working , the problem was the space between external: and the path
I figured out that there should be no space after the colon in the external

Thank you
Re: Using external jar file from eclipse plugin [message #1003598 is a reply to message #825042] Mon, 21 January 2013 15:33 Go to previous message
Lorand Zahonyi is currently offline Lorand ZahonyiFriend
Messages: 1
Registered: January 2013
Junior Member
Dear All,

I am a newbie at eclipse and I faced the same problem. Till now I didn't find any working solution. My solution would be:
1) my plugin's MANIFEST.MF file looks like this:
Bundle-ClassPath: external:$LIB_LOCATION$\itextpdf-5.3.0.jar,
2) and added this line to my eclipse.ini: -DLIB_LOCATION=C:\cuccok

I still get NoClassDefFoundError exception when I am using a class from itextpdf jar.

I am using Eclipse 4.2.1.
Tricky situation is that this solution is working on linux, but not on Windows XP. I tried all the followings:
- -DLIB_LOCATION=C:\cuccok
- -DLIB_LOCATION=C:/cuccok
- -DLIB_LOCATION=c:\cuccok
- -DLIB_LOCATION=file:C:/cuccok

What's wrong with this solution?

Many thanks for your help in advance!
Lorand

[Updated on: Tue, 22 January 2013 08:27]

Report message to a moderator

Previous Topic:No icon in Ubuntu Launcher for Eclipse
Next Topic:Else Error (Total newcomer)
Goto Forum:
  


Current Time: Tue Nov 25 23:40:14 GMT 2014

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

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