I have problems adding openCV to the buildpath of my eclipse-project. I have followed the instructions in the tutorial on this site: http://docs.opencv.org/2.4.4-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html#create-a-simple-java-project-in-eclipse
But executing the code fragment gives this console output:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv-java2.4.4 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at camStatisticsTests.RawTests.main(RawTests.java:20)
What do I have to do in order to get openCV working with java and eclipse. i want to use it as a normal java library.
I had the same problem.
It happened because I had a mistake with the 'Native library location' configuration:
Goto Eclipse -> Window -> Preferences:
Goto User Libraries:
Make sure that your native library location path is (change c:/opencv-2.4.9 to your own opencv folder):
C:/opencv-2.4.9/build/java/x64
and not:
C:/opencv-2.4.9/build/x64
(I missed the /java folder...)
The OpenCV java library is correctly linked to your Eclipse project.
The problem is the OpenCV native library which is not in the java.library.path. The exception is thrown by the line
static{ System.loadLibrary("opencv_java244"); }
which link the java library to the native one.
When you install OpenCV on your computer, it will also install a native dll library somewhere on your system, and when you call the System.loadLibrary, you tell java to search and load this library.
Your current problem is Java can not find this library in your System, either because the library is not in one of the java.library.path folders, or because you have not OpenCV installed (also take a look at the version, maybe you have not the 2.4.4 because the last is 2.4.5, in which case you will have to adapt the String).
I just noticed that your exception is about "opencv-java2.4.4". Be sure to have the right spelling of the form "opencv_java244", in your System.loadLibrary call.
I also redirect you to one of my answer, which is related to JavaCV, but that explain in more details what is going under.
I found a solution. The actual dll is located in the openCV\opencv\build\java\x64\ folder. In my case, its name is opencv_java247.dll, so I have changed System.loadLibrary("opencv_java244") to System.loadLibrary("opencv_java247") in my java code. I also put the native library location as E:/Sagar_tools/tools/openCV/opencv/build/java/x64 (which is my full path to the dll).
For me, Eclipse > external jar > native library config = opencv/build/lib
worked
I have found the solution. The tutorial skips the step, where one has to add a dll to the "native build path". The dll is located in "opencv/build/java/x86" for 32-bit java i guess. although i dont know why this is the case. Would be nice, if someone could explain that.
Change the code to System.loadLibrary("opencv_java244")
hope you would set the native path to correct folder and opencv jar has set in build path
Related
I just added lwjgl 3.1 to a project in Intellij IDEA. To verify everything was done correctly I tried to run the guide code in the webpage (https://www.lwjgl.org/guide), but when compiling the following error came out:
"Exception in thread "main" java.lang.NoClassDefFoundError: Could not
initialize class org.lwjgl.system.MemoryAccess"
After a google search I found out that the possible error is in the configuration of the native libraries, which I have added when configuring the library in the project.
When LWJGL was downloaded from the webpage, I got a a zip file with all the jar files of the modules (classes, docs, natives and sources), what I did was to separate them accordingly and then add them as a single library in the global libraries section of the IDE.
Global Libraries
After this, the library appears as a module of the project.
Still, the program won't compile. Is there anything else I should configure?
You claim that this is a compile-time error, however, after looking through the documentation, I have found out that this is a runtime error, where you successfully compile, but the JVM is unable to find the class at runtime. To solve this, I would suggest merging your .jar output and the lwjgl jar using jarsplice to see if that fixes it. If it fixes it, the problem is with intelliJ not correctly adding your libraries to your jar.
I'm encountering a problem with the build of my JavaFX project with the Leap Motion.
When I run the file.jar, the application's window is opening, but when I call the leap motion, it's not working any more.
I have the following error :
Native code library failed to load.
java.lang.UnsatisfiedLinkError: no LeapJava in java.library.path
Yet, I have configured the buildpath. I have added the leapJava.jar, with the native library x64.
I don't understand why it doesn't work ?
Anyone with an idea ?
Thanks
The LeapJava.dll is missing or the Java library path is not set up correctly. Please have a look at the docs - setting up a project:
https://developer.leapmotion.com/documentation/java/devguide/Project_Setup.html
I have followed each step in the Eclipse section. :/
Firstly, since you haven't mentioned any specification about your system, I am answering this in context with a 64 bit Ubuntu machine.
You will posses a libLeap.so and a libLeapJava.so in 'YourDeveloperKitDirectory'/LeapSDK/lib/x64/ . These files should be copied to your /usr/lib and the configuration/bulid path (if using IntelliJ IDE -> 'Edit Configurations'->'Application'->'configuration'->'VM options'->"-Djava.library.path=/usr/lib") should be appropriately stated.
Save and run your application.
I had this problem, what solved it was adding -Djava.library.path=/Path/to/LeapDeveloperKit_2.3.1+31549_mac/LeapSDK/lib to the command line call for the .jar file. (make sure your developer kit is the right version)
So rather than:
java -jar leapMotionProgram.jar
It had to be:
java -jar -Djava.library.path=/Path/to/LeapDeveloperKit_2.3.1+31549_mac/LeapSDK/lib leapMotionProgram.jar
I got the following Error as I compiled my program using the jlwgl and the slick library:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in
java.library.path
There are really many posts on that ! But I really didn't get the solutions of any of them. I think, that for example the description on this site probably explained everything . But I don't know what they mean by:
Specify the path to it using -Djava.library.path=
It would be very kind if you could give me a step by step explanation for dummies.
I am using ubuntu 12.04 and my IDE is eclipse
From this question:
Go to the library settings for your projects and for each LWJGL library go to the tree view in the library tab. Each library has items for source, javadoc and native library locations.
Select project, right click->properties, "java build path", "libraries" tab, select a jar, expand it, select "Native library location", click "edit...", folder chooser dialog will appear)
I am very new to Java and I am trying to run a program I got from a friend. I keep getting this error and I'm unsure how to solve the problem.
Application is starting. Fetching data. Please wait... (approx. 10s)
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-cocoa-4236 in java.library.path
no swt-cocoa in java.library.path
Can't load library: C:\Users\Andrew.swt\lib\win32\x86_64\swt-cocoa-4236.dll
Can't load library: C:\Users\Andrew.swt\lib\win32\x86_64\swt-cocoa.dll
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:331)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:240)
at org.eclipse.swt.interal.C.<clinit>(C.java:21)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:101)
at view.MainWindow.open(MainWindow.java:77)
at view.MainWindow.main(MainWindow.java:65)
Apparently I'm missing the SWT library (swt-cocoa-4236 and/or swt-cocoa?), but I have no idea where to get it. That statement probably reveals my ignorance. If anyone could even point me in the right direction to where I might be able to solve the problem I'd be very grateful. Thanks!
Seems like the program that you are running is not built for your OS. SWT is OS dependant and JVM depedant. All SWT programs will use swt.jar which will be different based on the underlying OS. The one the program is using is built for Mac OS and seems like you are running that on a non-Mac system.
Regarding 'How to solve it', it depends on how the program that you are running is packaged.
Check the java version you are using and download appropriate SWT jar file.
I think Mubin (i.e. the above answer) is correct. here is where you can download the specific version of SWT.jar for your environment http://www.eclipse.org/swt/.
(I am answering your question for "I have no idea where to get it.")
little late to the game, but i just had the same problem and found this solution:
Here's what worked for me:
Right Click on your Project Folder of your HelloWorldSWT Project-> Properties -> Java Build Path -> Tab 'Projects'
Expand the 'org.eclipse.swt.cocoa.macosx.x86_64' folder by clicking on the arrow left to it
Select 'Native library location' and click Edit
Click the Workspace Button and select 'org.eclipse.swt.cocoa.macosx.x86_64', then click ok (serveral times).
That did the trick ... Ma-an
java.lang.UnsatisfiedLinkError: no JMagick in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1754)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
when trying to use the code
ImageInfo info;
try {
info = new ImageInfo();
//image = new MagickImage(info);
} catch (MagickException e) {
logger.error(InsightsHelper.getStackTrace(e));
}
any ideas why this is happening? I'm using eclipse on OSX
You need to add the binaries that you compiled to the path so that Eclipse can see it.
First add JMagick.jar as a library, then in the the project properties-> Java Build Path -> Libraries, you click on the jmagick jar that you added to this project and edit the location for "Native library", which in this case it'll be where libJMagick-6.2.6.dylib is located since that's what the link that you provided says.
The simple answer is that the JVM is trying to find a native library used by JMagick, and failing. Either you don't have the native library at all, or it is not where the JVM is looking for it.
I downloaded a package for osx from here: joggame.com/software/jmagick.html ran the configure/make/make install and all went well. What else would I have to set up for java to find it?
You need to figure out where "make install" installed the native DLL and tell Java to look for it in the right place:
If you are launching from within Eclipse, follow the procedure in trigoman's answer.
If you are launching from the command line, directly or via a script, then you need to include this option (or the equivalent) in your java command:
java -Djava.library.path=/some/folder/ ....
Note that this is a JVM option and has to go before the classname.