external jars

Discussion in 'Plugin Development' started by hardcorebadger, Jan 14, 2011.

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

    hardcorebadger

    hey! I was wondering if there is a way to include and use external jars in a plugin???
    any help or comments would be greatly appreciated
    - hardcorebadger
     
  2. Offline

    JMEYER

    Create a folder titled "lib".
    Place your external jars in this folder.
    Right click the jars and select "Add to Build Path".

    Done :)
     
  3. Offline

    apexearth

    I've tried that as well as using some URL class loaders and I can't seem to get a mysql driver to be visible to the code. No matter what I do I get the ClassNotFoundException. I've tried positioning the jar in a number of different areas but nothing seems to work. I read some things about visibility troubles of loaders inside of loaders but that's all beyond my knowledge. I have been programming for many years but Minecraft is the first time I've touched Java so I am in the dark on this. Help would be awesome.
     
  4. Offline

    hardcorebadger

    Ya I'm trying to use javamail. Well, I have the jars in the libs folder and I have my plugin ready. Our server hasn't switched from Hey0 yet, were down.. idk what we're waiting for. I'll tell you how it goes wen we get it going.
     
  5. Offline

    JMEYER

    I managed to use apache's IO package without any problems. Don't know what to tell you.
     
  6. Offline

    Afforess

    You also need to add any external, custom jars in your jar's manifest's class-path. Use google if you have no idea what I'm talking about.
     
    apexearth and JMEYER like this.
  7. Offline

    hardcorebadger

    I just figured out how to set the classpath in java. Say this is the classpath: "/libs/*" how do u make a manifest for that??
     
  8. Offline

    Afforess

    Depends if you are compiling java via command line, or using an ide like Eclipse or Netbeans. Again, Google is a friend.
     
    apexearth likes this.
  9. Offline

    hardcorebadger

    sorry, i meant i just figured out how to set it in terminal
    --- merged: Jan 15, 2011 7:12 AM ---
    Well, im using Eclipse to code it
     
  10. Offline

    Afforess

    http://forums.macrumors.com/showpost.php?p=5617639&postcount=3

    Once you have a manifest set up, you can edit manually or via command line for the class-path. If you need to see some kind of example, MinecartManiaAutocart uses the classpath in it's manifest file. Use 7z or a similar archiving tool to tear the jar apart and a text editor to view the manifest.
     
    apexearth likes this.
  11. Offline

    hardcorebadger

    so I make the manifest out of the src file and then look at it in textEdit?
     
  12. Offline

    apexearth

    Ahh, it seems that must be the answer I needed. I am using Eclipse and even though I have the jar in the build path, it is not making it's way into the manifest. If I figure that out, I should be golden. Thanks for your help!


    -----Edit-----

    I had Eclipse generate the manifest (as it had been, but empty) and save i to my workspace. I then edited it manually in my work space and then I set up the export to use the existing manifest instead of generating one.

    Example of my Manifest:

    Manifest-Version: 1.0
    Class-Path: ../lib/mysql-connector-java-bin.jar

    And, it worked!
     
  13. Offline

    hardcorebadger

    thanks for the help guys! As soon as we have bukkit ready I'll tell you how it went!
    --- merged: Jan 15, 2011 6:40 PM ---
    btw minecartmania rocks
     
  14. Offline

    Afforess

    Glad I was able to help. (I just learned how to mess with the class path 2 days ago myself. ;) )
     
  15. Offline

    hardcorebadger

    while this is kinda off topic, im getting the done loading error, and ive tried EVERYTHING to fix it but minecraft just wont work
     
Thread Status:
Not open for further replies.

Share This Page