Jump to content

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


TorRS

Recommended Posts

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 :)

Link to comment
Share on other sites

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");
    }
}
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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