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:
I downloaded the SDK from https://www.logitechg.com/en-us/innovation/developer-lab.html
I extracted it
I made a new Java project in NetBeans
I added the logiled.jar file to my new project as a dependency
I made a new class and copied the simple test program from the documentation (code is below)
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
Copy the SDK’s Lib\logiled.jar to your project’s directory.
Configure your project’s Java Build Path to include the logiled.jar.
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();
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
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.
then I added the logiled.jar as image below
good news when I run the code I get no exception. output below
and when I try to use code completion netbeans lists the functions nicely.
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
Related
I am trying to create a Spigot plugin that allows players to use a compass to track other players. While exporting and running the server, I noticed that it was giving me an error:
[21:57:15 ERROR]: Could not load 'plugins\Manhunt.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:172) ~[patched_1.16.5.jar:git-Paper-683]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:148) ~[patched_1.16.5.jar:git-Paper-683]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:389) ~[patched_1.16.5.jar:git-Paper-683]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:252) ~[patched_1.16.5.jar:git-Paper-683]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1066) ~[patched_1.16.5.jar:git-Paper-683]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:290) ~[patched_1.16.5.jar:git-Paper-683]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 7 more
I have never seen this error before and I'm not sure how to fix it. I have made sure to export the .yml file while in Eclipse, but it still shows me this error.
The plugin.yml file is a required part of a SpigotMC plugin that defines some basic information about the plugin like its name and the version of the Spigot API that it uses. For example, here's one for a Minecraft plugin I'm currently working on.
The error you're getting comes from that file not getting bundled into the jar. As a result, when the Spigot server tries to load your plugin, it can't find the plugin.yml because it's literally not present in your compiled jar.
I recommend setting up a build system like Gradle or Maven that will handle the complexities of building the jar for you independent of the IDE you use.
Set up a SpigotMC plugin using Maven
Set up a SpigotMC plugin using Gradle
I personally use Gradle, so feel free to see how I implemented it in one of my plugins. If you'd prefer Maven, there are many examples available including the popular Multiverse-Core.
You need the plugin.yml to run your plugin. If you're using spigot or bukkit, you should make your plugin.yml inside the src folder, in there, you need to include a minimum of:
name: (plugin name, no spaces allowed in name)
author: (your name)
version: (your plugin version)
api-version: (use 1.14)
main: (your main class)
description: (optional description, otherwise delete this line)
then you can export or rebuild the jar
This is an example of what my plugin.yml looks like:
name: ThornsPlugin
version: 1.0
author: MOREORLESS
api-version: 1.14
main: com.MOREORLESS.plugin.plugin
description: MC Stuff
Learn more about Plugin.yml here: https://www.spigotmc.org/wiki/plugin-yml/
I recently installed Eclipse 2020-06 and am using JDK 10.0.2. I wanted to test Eclipse using a simple Hello world program:
package eclispeTest;
public class eclipseTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello");
}
}
But I get the error: Error occurred during initialization of boot layer java.lang.module.FindException: Module eclispeTest not found
One quick fix I see for this to delete the module-info.java file but when I do this I get the error: Error: Could not find or load main class eclispeTest.eclipseTest Caused by: java.lang.ClassNotFoundException: eclispeTest.eclipseTest
I saw one potential fix that told me to go to "Check your project build-path and enable specific output folders for each folder. Go one by one though each source-folder of your project and set the output folder that maven would use."
from: Eclipse - java.lang.ClassNotFoundException
But I am new to Eclipse and have no idea what they are talking about.
I have also noticed that when I open the problems tab at the bottom of Eclipse there is one problem that is repeated about 8 times: Description Resource Path Location Type The project was not built due to "Failed to init ct.sym for C:\Program Files\Java\jre-10.0.2\lib\jrt-fs.jar". Fix the problem, then try refreshing this project and building it since it may be inconsistent eclispeTest Unknown Java Problem
Could someone help me figure out what I should try, with baby steps for how I should do it.
Thank you in advance.
PS in case it helps here is a picture of my Eclipse window after I try to run my code:
EDIT: I made a new java project and below is my java project cration window
(I still got the same error)
Fist of all, In order to work the line " System.out.println("Hello");"
you will require two classes
1)java.lang.System
2)java.io.PrintStream
using above two classes the code runs.you don't have to import these class,because JRE(Java Runtime Environment) automatically does for you.
If you are gettting this error
Error occurred during initialization of boot layer java.lang.module.FindException: Module eclispeTest not found
Which means You didn't setup your "Java project" properly with "JRE"
Let create new project to solve this problem
1)Open Eclipse IDE
2)click FILE (top left most)
3)New
4)java project
5)give you project name (make sure that- "use default location checkbox" clicked)
6)IN JRE section - select use an execution environment JRE(edition as required)
7)Then click finish
This would have solved your problem , go create a Class do your eclipseTest. This time it should work.
java project creation should look like this
I am currently working on a Play 2.1 project, in which requests to the web-service will handle downloading user-supplied images, re-sizing and re-cropping them, and also filtering out known bad photos (for example, we don't want users to upload company logos). We are trying to use OpenCV to handle the back-end work, but I can't seem to get IntelliJ to add the OpenCV jar in a way that works with the java project.
I've been able to build OpenCV from source, without issue. This left me with the following folder:
/home/charles/opencv/release
Inside this folder, I have three files of interest:
bin/opencv-246.jar
lib/cv2.so
lib/libopencv_java246.so
If I try to add the jar file to IntelliJ as a new Java library, it seemingly finds all the classes/methods, and I can write code using the auto-complete. I can also click on the respective classes or methods, and it brings me to the right files.
However, when I try to run the Play project, I get this error:
[info] Loading project definition from /home/charles/Github/ImageProject
[info] Set current project to ImageProject (in build file:/home/charles/Github/ImageProject/)
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
Server started, use Alt+D to stop
[info] Compiling 1 Java source to /home/charles/Github/ImageProject/target/scala-2.10/classes...
[error] /home/charles/Github/ImageProject/app/controllers/Application.java:7: error: package org.opencv.core does not exist
[error] import org.opencv.core.Core;
[error] ^
I've also tried adding a copy of the jar file directly into the project (so putting opencv-246.jar into ImageProject/lib), and then adding the java library from that location instead. But that just leaves me with a different error:
java.lang.UnsatisfiedLinkError: no opencv_java246 in java.library.path
I suspect part of the problem may be related to the native libraries that the Java OpenCV wrapper uses (file 2 or 3 above). In Eclipse, when you add a jar file, you can explicitly set the native library location, which makes OpenCV work fine. I've read suggestions of using this to fix the problem:
-Djava.library.path=/home/charles/opencv/release/lib
But that doesn't seem to work (though maybe I'm setting it in the wrong place? I've tried setting it as a JVM parameter in the run config for the project, and in the IDE settings, but neither seem to be used or respected).
Note: Just to clarify again, this is a Play2 project, not an Android project. There seems to be some Android-specific help out there, that isn't relevant in this case.
This feels like it should be a rather straight forward thing, but I've been spending several days trying to find an answer at this point, and still have nothing. Any ideas?
Additional details:
I also tried following the "Running SBT samples" of the OpenCV documentation here:
http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.html
And I also get a similar error:
charles#charles-VirtualBox:~/JavaSample$ sbt run
[info] Loading project definition from /home/charles/JavaSample/project
[info] Set current project to JavaSample (in build file:/home/charles/JavaSample/)
[info] Compiling 1 Java source to /home/charles/JavaSample/target/scala-2.10/classes...
[info] Running HelloOpenCV
Hello, OpenCV
[error] (run-main) java.lang.UnsatisfiedLinkError: no opencv_java246 in java.library.path
java.lang.UnsatisfiedLinkError: no opencv_java246 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1856)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at HelloOpenCV.main(HelloOpenCV.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
[trace] Stack trace suppressed: run last compile:run for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) Nonzero exit code: 1
[error] Total time: 2 s, completed Jul 17, 2013 5:11:39 PM
When you want to use OpenCV or any other native libraries on Playframework, You MUST run your application with "play start" command, not "play run".
"play run" command starts your application in development mode and "play start" command starts in production mode. I don't know every difference between them but one obvious thing is ,
Only when we use "play start", a new JVM for you application is launched and it loads native libraries you specified by System.load("/absolute/path/to/your/so/or/jnilib/inOSX/not/dylib/filename.jnilib");
How to load native lib is following.
Create Global.java which has empty package name. (refer this link )
public class Global extends GlobalSettings {
#Override
public void beforeStart(Application app) {
// TODO Auto-generated method stub
super.beforeStart(app);
String libopencv_java = "/Users/yoonjechoi/git/myFirstApp/target/native_libraries/64bits/libopencv_java246.jnilib";
System.load(libopencv_java);
}
}
then you can use classes of OpenCV in your Play application's controllers.
System.loadLibrary("opencv_java246") doesn't works. I don't know why. I don't have time to dig why. -_-;
Please give hints if you know why.
for windows 64 bit set
-Djava.library.path=/full-path/OpenCV/build/java/x64
I would have used the lib/libopencv_java246.so
It's always important to map the .so file to build library. It's suppose to work out of the box
I have a problem with the YUI Compressor for js: I've added version 2.4.7 to my build path in Eclipse ( tried with rhino jar and also without) - no effect whatsoever. I dont get compile errors, I can see the class I've created that implements org.mozilla.javascript.ErrorReporter, but when I try to run the compressor, I get:
java.lang.ClassNotFoundException: org.mozilla.javascript.ErrorReporter from BaseClassLoader#1d81fd2
I know this is an old question but I'm going to add an answer in case anyone else comes across this in a search.
I had the exact same problem. The issue was that yuicompressor-2.4.7.jar wan't in our shared maven repository and so wasn't getting downloaded by the yuicompressor maven plugin. To verify this check your local maven repository for the yuicompressor-2.4.7.jar (usually C:\Users\.m2\repository\com\yahoo\platform\yui\yuicompressor\2.4.7). If it's there then you have a different issue if it's not then this could well be your issue. To fix just upload yuicompressor-2.4.7.jar to your shared repository.
I am executing a junit test case
I got the following error,
A fatal error has been detected by the Java Runtime Environment:
Internal Error (classFileParser.cpp:3174), pid=2680, tid=2688
Error: ShouldNotReachHere()
JRE version: 6.0_18-b07
Java VM: Java HotSpot(TM) Client VM (16.0-b13 mixed mode windows-x86 )
Can any body please suggest the solution to resolve
I got the same problem, but with alot of googling I found the answer! See this page
Quote from the link:
# An unexpected error has been detected by Java Runtime Environment:
#
# Internal Error (classFileParser.cpp:2924), pid=5364, tid=6644
# Error: ShouldNotReachHere
That's because we are using Android's JUnit stub implementation. Go to Run -> Run As -> Run configurations again and in the recently created JUnit configuration Classpath's Bootstrap Entries remove Android Library
Then Add Library, using Advanced... button, and add JRE System Library and JUnit 3
Apply and Run
Try this, it worked for me.
You'll need to take this up with Sun -- looks like a JVM bug to me. If it's reproducible, you should be able to run java in such a way as to generate more details (e.g. -verbose, etc). If you can reduce it to a minimal case that triggers the bug (source code always helps!), that also goes a very long way.
http://java.sun.com/developer/technicalArticles/bugreport_howto/index.html
http://bugreport.sun.com/bugreport/crash.jsp
In the meantime, you might want to try it with a different JVM implementation (maybe even an older patch level of the Sun JRE).
Go to Run As -> Run Configurations... and select the configuration you are using.
Select the Class Path tab and select BootStrap Entries.
Click on Advance, then Add Library and select JRE System Library.
Bring it up and make it the first entry in the BootstrapEntries List.
Apply and Run...
Another possible explanation: hardware failure. Ruled out if you can reproduce the error on different machines.
I resolved this by
Quit eclipse
Delete the bin and gen directories in your project
Start eclipse
Rebuild your project
I just recently found solution for this issue that was posted by devdanke:
"As of 11-July-2010 and Android 2.1, the work around I use is to segregate tests into different classes. Any test(s) that don't call any Android APIs go into their own classes. For each of these classes, I remove the reference to Android in their Run Configurations, Classpath tab."
The problem with having it configured class by class is then is not possible to run all tests in project. Better approach is creating 2 test projects with different sets of libraries.
Standard Android JUnit Test project can be created following link, and sample test class looks like:
import android.test.AndroidTestCase;
public class ConverterTest extends AndroidTestCase {
public void testConvert() {
assertEquals("one", "one");
}
}
Then JUnit Test project can be converted from Android JUnit Test project by removing Android Library from project build path, and adding JRE System Library, and JUnit 3 library, and sample test class looks like:
import junit.framework.TestCase;
public class ConverterTest extends TestCase{
public void testConvert() {
assertEquals("one", "one");
}
}
I have had a similar problem, I found it was because I had generated a new activity with a main[] stub entry. Once I deleted the main[] code from the new activity templatye the error went away.
YMMV
This could be a JVM bug; see #Zac's answer. But it could also be that your junit test case is causing a corrupted bytecode file to be loaded. Try rebuilding all your .class files, and if that does not fix the problem try refetching any external libraries that your code depends on.
Do you run on a supported platform (Windows, one of a few Linux versions?) If not, that is the first to try.
If you ARE on a supported platform, then downgrade to _17 and see if THAT helps.
Then make a bug report to Sun and hope they will fix it someday (unless you want to give them money for fixing it faster).
Go to Run As -> Run Configurations->classpath->BootStrap Entries
Click on Advance, then Add Library and select JRE System Library as a first entry.
Apply and Run...
I am not sure whether you were able to reach the solution for your problem or not but your question just popped up while I was searching for the solution for the same problem I am facing. And I got one solution from the stack itself, so just thought to share a link with you if that aids you by any means. The link is as below:
Can't run JUnit 4 test case in Eclipse Android project
Another possible reason (for future references):
I had accidentally copied in a main method in my code, causing Eclipse to recognize the project as a java application, thus launching it with that configuration.
To solve it I went into Run > Run Configurations... and then changed from my presumed main in java application to the main activity of my android application simply by choosing it in the left column.