Jump to content

I'm trying to turn some packages into jar files so I can use them but I get java.lang.NoClassDefFoundError


Recommended Posts

Posted

No matter what I found online didn't work, I tried exporting as jar and runnable jars, and I even switched from Eclipse to IntelliJ and played around with the artifacts without success.

In the script, everything looks alright but when I run the script I get the java.lang.NoClassDefFoundError.

Would appreciate some help and guidance,

Thanks :)

Posted

Yes, the script part works fine but when i try to turn one of my classes into a jar file and import them in another project it wont work

If they are in the same project everything works as intended but the moment i try to export the class as a jar and import it and do everything the same it wont work and i get the error
Ex code:
Main class:

@ScriptManifest(author = "Me", name = "example", info = "", version = 1, logo = "")
public class Main extends Script {

    @Override
    public int onLoop() {

        Printer.testPrint(this);

        return 1000;
    }
}

Another class that I'm trying to turn into a jar file for the purpose of making it easier to implement in all of my scripts:

import org.osbot.rs07.script.MethodProvider;

public class Printer {
    public static void testPrint(MethodProvider mp){
        mp.log("Hello world");
    }
}
Posted (edited)
9 hours ago, TorRS said:

Yes, the script part works fine but when i try to turn one of my classes into a jar file and import them in another project it wont work

If they are in the same project everything works as intended but the moment i try to export the class as a jar and import it and do everything the same it wont work and i get the error
Ex code:
Main class:

@ScriptManifest(author = "Me", name = "example", info = "", version = 1, logo = "")
public class Main extends Script {

    @Override
    public int onLoop() {

        Printer.testPrint(this);

        return 1000;
    }
}

Another class that I'm trying to turn into a jar file for the purpose of making it easier to implement in all of my scripts:

import org.osbot.rs07.script.MethodProvider;

public class Printer {
    public static void testPrint(MethodProvider mp){
        mp.log("Hello world");
    }
}

as far as I know you can't use jar files as dependency on OSBot as it does not read them when starting a script.
When developing on the OSBot SDN we do have a dependency package which we can access from every script on that repo

Edited by Khaleesi
Posted

Do you have any suggestions on how to approach this problem, the only other thing I can think of currently is just copy-pasting the code from script to script and I'm trying to avoid that.

I would prefer if I was able to change it once and be able to import it in all the scripts.

Thanks again for the responses guys :)

Posted
13 hours ago, TorRS said:

Do you have any suggestions on how to approach this problem, the only other thing I can think of currently is just copy-pasting the code from script to script and I'm trying to avoid that.

I would prefer if I was able to change it once and be able to import it in all the scripts.

Thanks again for the responses guys :)

Are you outing the dependency into the compiled jar?

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...