While exporting in eclipse I choose "Package required libraries into generated jar".
The jar file works only in my machine. However, when I test it on other machine it gives this Exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
at com.googlecode.javacpp.Loader.load(Loader.java:489)
at com.googlecode.javacpp.Loader.load(Loader.java:431)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:136)
at mains.<clinit>(mains.java:25)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:266)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Short answer
You must install OpenCV (as mentioned in JavaCV requirements) and JavaCV on the system in order to use JavaCV. As you probably installed them for development on your computer the application work, but the other machine probably has not them installed and thus the jar does'nt work.
Long answer
The problem is not the JavaCV library, which appears to be correctly included into your jar as shown by the lines:
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
at com.googlecode.javacpp.Loader.load(Loader.java:489)
at com.googlecode.javacpp.Loader.load(Loader.java:431)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:136)
The fact is JavaCV is build on top of OpenCV. OpenCV being a C++ library, the only way to use it from Java is to use JNI calls.
JNI require two components:
A java library (usually with extension *.jar) containing java method that calls native library
A native library (usually with extension *.so for linux or *.dll for windows) that "do the work", in this case that "use OpenCV library"
The first one is provided by JavaCV and included into your jar application. The second one is system dependent (Os, architecture, ...) and must be into the java library path.
This is the actual error: it can not find libjniopencv_core.so into java.library.path. The jniopencv_core library is provided by JavaCV too but is installed somewhere on the system (/usr/lib/ for instance) and thus not included into the final jar.
Even if you find a way to include it into the final application, this library will need to use OpenCV libraries which are not installed on the system too. To summarize the needs:
JavaCV java library, that will call (with JNI):
JavaCV native library, that will use:
OpenCV libraries, that will really do the work.
Without one of this point the application will not work. Thus OpenCV and JavaCV must be installed into the system.
Related
I have compiled a Matlab algorithm to a java.jar file and successfully run the same algorithm in java.
to use the matlab function in java, i imported the generated jar file and also the
javabuilder.jar.
now what is :
javabuilder.jar ?
Also it is possible to choose at compilation settings between
Runtime downloaded from web
and
Runtime included in package
I set Runtime downloaded from web and included only the two jar files to my project and could run the algorithm.
Where is the Matlab runtime necessary? and can i just use my Jar files also on a linux computer?
The javabuilder. jar contains the wrapper functions to communicate with the matlab runtime.
The matlab runtime is written in c++ and has to be installed on the system where the javabuilder + matlab function jar is used.
The runtime installer is included in the package file that is created by matlab to download the runtime from web or can be included with the package.
I've just been exposed to a large non-trivial CMake/Eclipse based C++ project. One of the build targets is Windows/nmake based. In the final step of building an executable, the linker throws LNK1104: cannot open file 'python27.lib'. This is correct, because Python 2.7 hasn't been installed.
Problem is, I cannot find any references to this library in cl.exe's command line. Also a grep on the whole project directory (including eclipses .metadata directory) won't find anything plausible. Deleting all the cmake generated build stuff didn't help too.
The real question is, if MSVC-based libraries (import or static ones) have any mechanism to request additional libraries during the link step implicitely. There are a few pre-compiled ones in the mentioned project. I simply need the vocabulary, where to begin a more qualified search regarding the error cause.
I found the answer here:
Puzzling dependency of Boost.Python 1.54 (debug build) to Python27.lib on Windows
Basically, the culprit is a #pragma comment() directive inside the boost libraries.
I'm using LeapJava.jar to write a simple JDK program to interface with the Leap. I've roughly followed this article: Developing for the Leap Motion controller in Scala and in theory it's all very simple. However, when I try to run the program it fails with a RuntimeException when it tries to connect to the Leap device:
Native code library failed to load.
java.lang.UnsatisfiedLinkError: no LeapJava in java.library.path
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
I've followed the steps in the Leap documentation but since I'm using Ubuntu (and sbt) there aren't clear instructions that relate directly to this situation. I've tried various different parameters for the java.library.path argument:
pointing at the ./lib dir in the project (which contains LeapJava.jar)
using the Leap SDK's lib directory
absolute path to the Leap SDK's lib directory
the x86 dir within the LeapSDK's lib directory
symlinking the LeapJava.jar file into the x86 directory and using that
I get the same problem running it in IntelliJ (set up as described in the Leap docs linked above) or from the command line. e.g.
sbt -Djava.library.path=.:/<path to LeapSDK>/lib run
I've added the LeapJava.jar to the classpath in sbt (it's in the lib directory) and the project compiles fine.
Any advice (particularly as I'm on Linux, which is poorly documented) would be most welcome.
Copy the .dll files in the the project(your current working directory) folder since it looks for the native libraries in that particular folder.
From the Readme in the Leap Motion Linux package:
Q. ...Sample.java compiles, but when
attempting to run, I get an error about unable to load
libLeapJava.so
A. Java seems to have trouble searching for native
libraries without some guidance. Try:
LD_LIBRARY_PATH=. java -classpath .:LeapJava.jar Sample
which looks like it assumes the jar file and native libraries are in the same folder as your application.
I got things rolling in eclipse on Ubuntu by doing the following.
1)Select your project in the Package Explorer area and press a right click on it.
2) Select Build Path → Configure Build Path... option.
3) In the appearing window, select the Libraries tab.
4) Then, expand the JRE System library option and select the Native library location.
5) Click on the Edit button at the right panel
6) click external folder.
7) navigate to your download of the sdk .../LeapSDK/lib/x64
if you are on a 32 bit system use x86
You should now be able to use LeapJava.jar without error.
I am pretty new to hadoop & ubuntu so please bear with me. I find it very inconvenient to compile my hadoop .java files from command line. So I have created an eclipse project & imported all the hadoop libraries so that the eclipse does not throw any reference errors. And it does not. However when I run the files as a standalone java application I get the following error
WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
I am running on ubuntu and I have researched this problem elsewhere on web. I do not expect to see this error since the only difference is that I am running it within eclipse and not from command line. Where I am going wrong. Is there a specific way in which I need to add hadoop dependencies to my hello world hadoop projects? Will a simple buildpath configuration and importing of the necessary libraries not suffice? Appreciate all your responses.
you can try right-clicking the Project, ->Build Path -> Configure Build Path
Go to your src folder, point to "Native Library", then edit the location to the location of your hadoop native library folder (normally: ~/hadoop-x.x.x/lib/native/"folder-depending-on-your-system")
It is a warning and not an error which tells you that there is some problem in loading the native libraries which Hadoop makes use of. It should not have any negative impact on your job's output though. Remember Hadoop has native implementations of certain components for performance reasons and for non-availability of Java implementations. On the *nix platforms the library is named libhadoop.so. Using Eclipse doesn't make any difference the way Hadoop works. It's just that your Eclipse is unable to load the native libraries due to some reasons.
One possible reason might be that there is some problem with your java.library.path. You can configure Eclipse to load the proper libraries by configuring the build path as per your environment. To know more about Hadoop's native libraries, and how to build and use them you can visit this link.
Just starting to learn scala.. I can't seem to figure out how to compile something into a standalone application. I think I almost have a working .jar file, but keep getting a Main-Class error even though it's in the manifest,
Scala programs require at a minimum the scala-library.jar file that accompanied the Scala Development Kit whose compiler you used to compile the sources. This is in addition to any 3rd-party Java (or Scala) libraries you might use. So from the perspective of building a stand-alone application (i.e., one that can be launched with a java -jar ... command) you must treat the scala-library.jar like a 3rd-party library.