tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

java.lang.UnsatisfiedLinkError: no tdjni in java.library.path: #2358

Closed Ioakeimis closed 1 year ago

Ioakeimis commented 1 year ago

I successfully managed to execute all the commands mentioned in the build instructor generator for JAVA on Apple silicon. When I try to just run the main method in the Example.java class I get the following error:

java.lang.UnsatisfiedLinkError: no tdjni in java.library.path: /Users/username/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:. at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2444) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:848) at java.base/java.lang.System.loadLibrary(System.java:2047) at org.drinkless.tdlib.Client.(Client.java:18) at org.drinkless.tdlib.example.Example.main(Example.java:302) Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void org.drinkless.tdlib.Client.nativeClientSetLogMessageHandler(int, org.drinkless.tdlib.Client$LogMessageHandler)' at org.drinkless.tdlib.Client.nativeClientSetLogMessageHandler(Native Method) at org.drinkless.tdlib.Client.setLogMessageHandler(Client.java:139) at org.drinkless.tdlib.example.Example.main(Example.java:302)

There was another issue in the closed issues section that had the same error but I was unable to benefit from it in any way :(

levlam commented 1 year ago

You need to specify java.library.path to JVM, For example, java '-Djava.library.path=.' org/drinkless/tdlib/example/Example.

Ioakeim commented 1 year ago

Where do I do/specify this? I am using IntelliJ as an IDE

levlam commented 1 year ago

https://stackoverflow.com/questions/19308010/how-to-set-the-java-library-path-in-intellij-idea

Ioakeimis commented 1 year ago

Perfect! I have managed to make it work by following your link and then specifying "../../../td/tdlib/bin" as Djava.library.path. Thanks :)

Valentyna12 commented 1 year ago

???

сб, 18 мар. 2023 г., 21:43 Aliaksei Levin @.***>:

You need to specify java.library.path to JVM, For example, java '-Djava.library.path=.' org/drinkless/tdlib/example/Example.

— Reply to this email directly, view it on GitHub https://github.com/tdlib/td/issues/2358#issuecomment-1474969288, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZCSN4TJKUU2Q4B2C4MEIG3W4YF43ANCNFSM6AAAAAAV67KCHQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

sizov2405 commented 4 months ago

Aliaksei, I cloned the project, built it for Mac/Apple silicon following the instruction, then I imported the project to the Intellij and added a VM argument -Djava.library.path=. but I still get:

java.lang.UnsatisfiedLinkError: no tdjni in java.library.path: . at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2429) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818) at java.base/java.lang.System.loadLibrary(System.java:1989) at org.drinkless.tdlib.Client.(Client.java:18) at org.drinkless.tdlib.example.Example.main(Example.java:301)

image
levlam commented 4 months ago

You need to specify path to tdjni.dylib as java.library.path. If you don't run the example from command-line, then "." is highly likely to be a wrong path.

sizov2405 commented 4 months ago

You need to specify path to tdjni.dylib as java.library.path. If you don't run the example from command-line, then "." is highly likely to be a wrong path.

It works! Thanks!