Jump to content

[1.15.1] Can't load external .jar library? I got error NoClassDefFoundError for external library


Recommended Posts

Posted

IDE: IntelliJ IDEA

Forge Version: 1.15.1-forge-30.0.36

 

Hello,

 

I trying to create minecraft mod that send ping to server every 1 second.

and I want to use ping wrapper library http://icmp4j.org/d/index.html for this mod, then I downloaded this and copy icmp4j.jar to `libs/icmp4j.jar` and `src/main/resources/META-INF/libraries/icmp4j-1.0.0.jar`.

 

It works well on runClient task, but builded jar file doesnt work.

[1412020 02:31:36.932] [Thread-989/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.NoClassDefFoundError: org/icmp4j/IcmpPingUtil
[1412020 02:31:36.933] [Thread-989/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.naari3.pingtoserver.Pinger.ping(Pinger.java:27)
[1412020 02:31:36.933] [Thread-989/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.naari3.pingtoserver.Pinger.lambda$pingAsync$0(Pinger.java:54)
[1412020 02:31:36.933] [Thread-989/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at java.lang.Thread.run(Thread.java:745)

 

I found out after read some docs this library was not registered to maven and I think it need to make `src/main/resources/META-INF/libraries/icmp4j-1.0.0.jar.meta` like this.

Maven-Artifact: org.icmp4j:icmp4j:1.0.0

 

finally, I added manifest attribute `ContainedDeps` to `build.gradle` like this

jar {
    manifest {
        attributes([
            "Specification-Title": "pingtoserver",
            "Specification-Vendor": "naari3",
            "Specification-Version": "1",
            "Implementation-Title": project.name,
            "Implementation-Version": "${version}",
            "Implementation-Vendor" :"naari3",
            "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),

            "ContainedDeps": "icmp4j-1.0.0.jar" // here
        ])
    }
}

 

but that doesnt work well (caused by same error at first)

 

here is my current sourcecode. https://github.com/naari3/PingToServer/tree/13bae40aae18cc9e0657826162a4c1ee4ac3ff28

 

any idea for this?

thanks.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.