Use of external jars in plugin

Discussion in 'Plugin Development' started by Farstucker, Mar 17, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Farstucker

    Hello

    It seems it is rather impossible to include jars within your own plugin

    I'm trying to use some external jars in a plugin. When I run my code with my own main class it works, however, once used as a plugin it has a ClassNotFound Exception. I think is is because Bukkit ignores the internal jars of my plugin jar. Something to do with the ClassLoader used?

    And another problem I encountered: I want to make use of a class that dynamically looks for other classes given in a certain package: Bukkit is again looking for that package in it's own class directories and thus can't find any class files (these are servlets);

    The jars I'm trying to use are from a project called Grizzly, it is a minimalistic webserver that allows you to run servlets without the need of Tomcat or GlassFish

    I already found out that when you extract the directory structures of the in the main Bukkit jar it kinda works... My servlets are picked up, but are not able to talk back to my plugin... (again, ClassNotFound).When I place my other plugin classes in the main jar I only resolve the classNotFound, because, of course, the plugin is never initialized properly and can't talk to the actual server...

    Anybody any ideas?

    I suppose using the source of all those jars instead of including the jar file would be a possible solution... But it just would be nice if you could make use of third party jars in your plugin.
     
  2. Offline

    DiddiZ

    Do you add the class path to the MANIFEST.MF?
    Class-Path: pathToJar/jardata.jar
     
  3. Offline

    NathanWolf

    Right- adding the classpath to the manifest file is super important!

    Also, look into Maven. It can set up your classpath/manifest for you- it will also re-package jars. So, for instance, if you're binding to a truly external lib (not another bukkit plugin), you can just roll it up in your jar (assuming the licensing is ok, etc...)

    I do this in the SQLite support plugin for Persistence, using Maven to pack up the sqlite drives in the plugin itself.
     
Thread Status:
Not open for further replies.

Share This Page