Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Using classes from external .jar


    Recommended Posts


    When I import an external .jar with some variables and code, then I try to use it in my script and all compiles without errors when I run it it does nothing. If I put it in onLoop() the scripts starts but does nothing, if I put it in class scope or in another class then the script doesnt start at all. What am I doing wrong? Is it even possible for me to create a library with some dreambot functionality and export it in .jar for later importing and reuse in multiple scripts?

    Thank you.

    Link to comment
    Share on other sites

    Did you check if the build path was configured correctly, and that the external .jar file you are trying to use exported correctly to begin with?  Not sure the specifics of the .jar you are trying to use but could you attempt using it in a non DreamBot script and see if you could get it working there?

    Link to comment
    Share on other sites

    I have tried with the same .jar in a eclipse created java application and worked fine. It is exported correctly I opened it with winrar and the package folder is there and inside is the right .class file. The jar cointains 1 class that is in a package and the class contains a public static String variable that I tried to print out in the script class inside onLoop() by directly accessing (Library.string) that didn't work. So I tried to create an instance of the class in onLoop() then accessing the variable from that instance, also didnt work, finally I tried to create a another class in the script's .java file that has a String which gets its content from Library.string and then creating an instance of it in onLoop() also doesnt work. The same happend when I tried it with an integer value. All of this works if its a regular java app created in eclipse.

    I exported it to .jar with and added it as the script's projects external dependancy like so: http://prntscr.com/n9lncm .

    I am trying to figure out how to save my scripts methods in classes and export them to .jar in a library fashion so I can reuse them later in different scripts. Have googled on importing, java file types, dependancies and I can't find an error in my way. Is this how dreambot works? Will try exporting my code to regular .java files and then manually add them to script project's package and see if that works.

    Thanks for reply

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.