Adding Libraries To Plugin

Discussion in 'Plugin Development' started by ParanormalX, Jan 20, 2013.

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

    ParanormalX

    I am making a plugin that uses web input so I need it to scrape the webpage text. How can I make the plugin work on bukkit with the Jsoup libraries? http://jsoup.org
     
  2. Offline

    Terradominik

    you simply add the jar in your plugin jar
     
  3. Offline

    ParanormalX

    Then it fires errors in the bukkit console
     
  4. Offline

    Terradominik

    which errors ?
     
  5. Offline

    fireblast709

    ClassDefNotFoundException or ClassNotFoundException probably :p
     
    Terradominik likes this.
  6. Offline

    camyono

  7. Offline

    camyono

    But the system classloader!
     
  8. Offline

    EnvisionRed

    The issue is that the classes are present at build time, but not at run time. You need to package the library in your jar and it should work. If you're using eclipse, a plugin like "FatJar" can do that for you.
     
  9. Offline

    camyono

    So for me it works fine with manifest files. It is also supported by apache ant. Jar's generated by FatJar etc. will fail too if you do classloading things at runtime... so it doesn't matter. If you want to be safe that every class is loaded by the classloader you should check that every path, which contains jar's / classes is in the classpath while booting your app/plugin/etc.
     
  10. Offline

    EnvisionRed

    The classes have to be physically there for them to work, that's why Library plugins (Sync, PatPeter's SQL lib) have to be in the plugins folder (the bukkit classloader will have loaded them before your plugin) or packaged in your jar. This is the same, except since the lib he is trying to use isn't a plugin also, he needs to package it in his jar.
     
  11. Offline

    Sagacious_Zed Bukkit Docs

  12. Offline

    camyono

    EnvisionRed, @ all Sure there are many ways but it's not the common way. Because the classloader will load everything from all jar's. With this way you dont have the chance to load them on the fly. I think the biggest problem is that many people just read one two pages of the examples stuff, call themself a java programmer and fail with the easiest problems. There are alot of examples ( including the SUN/Oracle API ) and books ( with more than 300 pages!! ) to bring you up to the level of a professional. This language is not like making a Website with HTML. I would be happy if many would read this and spiritualize this topic to get the feeling that programming is nothing like baking rolls in 5 min in the oven, at all. ;)
     
Thread Status:
Not open for further replies.

Share This Page