MinnDevelopment / java-discord-rpc

Java bindings for https://github.com/discordapp/discord-rpc (using JNA)
Apache License 2.0
132 stars 38 forks source link

UnsatisfiedLinkError on release jar #37

Closed wodxgod closed 5 years ago

wodxgod commented 5 years ago

I've downloaded and imported the library to my project (from the "Releases" page), and for some reason, whenever I run my code, it spits out a stacktrace error (UnsatisfiedLinkedError) that it can't load the library.

Java SDK version: 1.8.0_191 Images of the code, stacktrace errors etc.: https://imgur.com/a/9WgX5fq

MinnDevelopment commented 5 years ago

Are you using one of the supported platforms? What is the exact error with stacktrace? Which jar did you use?

wodxgod commented 5 years ago

Are you using one of the supported platforms? What is the exact error with stacktrace? Which jar did you use?

I'm on Windows 10 and I used the "java-discord-rpc-2.0.1-all" jar file

MinnDevelopment commented 5 years ago

I just tested this with a completely bare project on windows 10:

C:\Users\minnced\test>run.bat
=== Test.java ===
import java.io.*;
import club.minnced.discord.rpc.*;

class Test {
    public static void main(String[] args) throws InterruptedException {
        DiscordRPC lib = DiscordRPC.INSTANCE;
        lib.Discord_Initialize("420321485757087746", null, true, null);
        DiscordRichPresence presence = new DiscordRichPresence();
        presence.details = "Testing RPC";
        lib.Discord_UpdatePresence(presence);

        System.out.println("RichPresence is working as intended");
        Thread.sleep(30000);
        System.out.println("Finished!");
    }
}
=== manifest.mf ===
Main-Class: Test
Class-Path: rpc.jar
Maniest-Version: 1.0
===================

C:\Users\minnced\test>javac -cp rpc.jar Test.java

C:\Users\minnced\test>jar -c -m manifest.mf -f test.jar Test.class

C:\Users\minnced\test>java -jar test.jar
RichPresence is working as intended
Finished!

Since a bare project works fine, I assume this is an issue with setup. Try using gradle instead which is a proper build tool rather than the built-in IDE artifact builder. The README explains how to add this as a gradle dependency. See Gradle Guides and java-discord-rpc as gradle dependency

MinnDevelopment commented 5 years ago

I'm assuming this was resolved since there hasn't been a response in over a week.

wodxgod commented 5 years ago

I'm assuming this was resolved since there hasn't been a response in over a week.

Sadly not. I've not been able to fix the problem

belohnung commented 5 years ago

same problem but on linux

MinnDevelopment commented 5 years ago

Same answer but for linux then. Use gradle and make sure your setup works.