How do I set up Logitech's LED Illumination SDK with Java?

766 views Asked by At

When a make a simple test program with Logitech's LED SDK and run it, I get an UnsatisfiedLinkError with the message:

C:\Users\cwa38\AppData\Local\Temp\LogitechLedJNI.dll4587977834410494064: Can't find dependent libraries

What I have done so far:

  1. I downloaded the SDK from https://www.logitechg.com/en-us/innovation/developer-lab.html
  2. I extracted it
  3. I made a new Java project in NetBeans
  4. I added the logiled.jar file to my new project as a dependency
  5. I made a new class and copied the simple test program from the documentation (code is below)
  6. I clicked "run" and got the UnsatisfiedLinkError described above

I see that the SDK download comes with some .dll files and a .lib file, but I have no idea what to do with these files. The included documentation makes absolutely no mention of them.

What am I doing wrong?

Here is my code:

import com.logitech.gaming.LogiLED;

public class Main {
    public static void main(String[] args) {
        LogiLED.LogiLedInit();
        LogiLED.LogiLedSetLighting(100, 0, 0);
        LogiLED.LogiLedShutdown();
    }
}

And here is the full documentation from Logitech (yes, it really is this short):

The following steps show how to make the Logitech SDK work with a Java program. Please adapt the steps to your game for things to work.

Steps

  1. Copy the SDK’s Lib\logiled.jar to your project’s directory.
  2. Configure your project’s Java Build Path to include the logiled.jar.
  3. Call the functions from the JNI wrapper in your Java code as follows:
    import com.logitech.gaming.LogiLED;

    LogiLED.LogiLedInit();
    LogiLED.LogiLedSetLighting(red,blue,green);
    LogiLED.LogiLedShutdown();
  1. Compile and run your program.

The full stack trace for the error I get is below:

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\cwa38\AppData\Local\Temp\LogitechLedJNI.dll4587977834410494064: Can't find dependent libraries
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:384)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:228)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:170)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2389)
    at java.base/java.lang.Runtime.load0(Runtime.java:755)
    at java.base/java.lang.System.load(System.java:1953)
    at com.logitech.gaming.LogiLED.<clinit>(LogiLED.java:205)
    at javaapplication1.JavaApplication1.main(JavaApplication1.java:20)
C:\Users\cwa38\AppData\Local\NetBeans\Cache\12.4\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\cwa38\AppData\Local\NetBeans\Cache\12.4\executor-snippets\run.xml:68: Java returned: 1
2

There are 2 answers

5
ozkanpakdil On

I tried to run your project in my netbeans but failed with

 project com.cwa380:KeyColors:jar:1.0: logitech:gaming:jar:9.00 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced

then I created a new project from ant, as long as you are using this logitech jar which is not really in maven repository, you dont need to have maven project.

netbeans create ant project

then I added the logiled.jar as image below project properties->libraries

good news when I run the code I get no exception. output below

execute output at the bottom

and when I try to use code completion netbeans lists the functions nicely.

logiled functions

here are my versions of tools

Product Version: Apache NetBeans IDE 12.4
Java: 17; OpenJDK 64-Bit Server VM 17+35-2724
Runtime: OpenJDK Runtime Environment 17+35-2724
System: Windows 10 version 10.0 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\ozkan\AppData\Roaming\NetBeans\12.4
Cache directory: C:\Users\ozkan\AppData\Local\NetBeans\Cache\12.4

in github I found https://github.com/larsgrefer/logi-led you may contact with Lars(@larsgrefer), looks like he knows how to use logitech SDK.

here is my project https://github.com/ozkanpakdil/spring-examples/tree/master/JavaApplication1 make sure you have added logiled jar in correct path to libraries

1
ekqeos On
  1. I added the logiled.jar file to my new project as a dependency

Need to add x64 version, not x86.

\Lib\JNI\x64\logiled.jar

should work.