Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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.

  • Author

Oh really, thank you for telling me that.

I hope it will be implemented :)

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.