I am using an exmplae from here to apply face recognition using opencv. I have extracted opencv at C:\. However, after running the provided example cod in Java, I get the following exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java341 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1865)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at detectingfaceinanimage.DetectingFaceInAnImage.main(DetectingFaceInAnImage.java:23)
I used System.out.println(System.getProperty("java.library.path")); to locate path for the java library but I have received numerous paths. Can you let me know how to fix thsi issue? (For Windows platform)
To solve this issue, needed to copy the .dll file from C:\opencv\build\java\x64 (as I am running a 64 bit operating system) into C:\Program Files\Java\jdk1.8.0_31\bin.
You should do these things:
Add the OpenCV Jar file in your project classpath (I think you
already did it)
Locate the OpenCV DLL file location where you extracted it, maybe it
looks like this:
C:\opencv\build\x64\vc15\bin
Then add this path in your system environment variable
In the end, restart your IDE (not your computer), and yes it is that!
Good Luck!!
Related
I am getting this error during my install of hadoop 3.2.1
I was told to follow this guide: https://towardsdatascience.com/installing-hadoop-3-2-1-single-node-cluster-on-windows-10-ac258dd48aef Everything is working until Step 6. when I try to run .\start-dfs.cmd
I have found solutions, but none worked.
All native files are added to bin from the github site (hadoop.dll etc) also added hadoop.dll to System32 folder
I also tried to edit the src code in InteliJ (adding a package org.apache.hadoop.io.nativeio) and creating a NativeIO.java class as the guide below:
Obtain and patch Hadoop
Hadoop is compatible with JDK 7 and 8. You may check if you have one (or more) of them installed.
The binary of Hadoop can be found at http://hadoop.apache.org/releases.html. Extract all files to a safe
place. For example, C:\hadoop-2.7.3.
Then download patch files from https://github.com/srccodes/hadoop-common-2.2.0-bin/archive/master.zip.
Extract (and replace) all files to the bin folder of your Hadoop binary. In this example, the full path will be C:\hadoop-2.7.3\bin.
Developing with IntelliJ IDEA
The IntelliJ IDEA is a powerful IDE for Java development. You may have it already installed on your
working computer. If not, grab one from https://www.jetbrains.com/idea/. The “Community” version if free
for non-commercial uses.
A nice step-by-step guide about this part can be found at https://mrchief2015.wordpress.com/2015/02/09/compiling-and-debugging-hadoop-applications-with-intellij-idea-for-windows/.
Troubleshooting: 1. You get an exception when debugging that says
Exception in thread "main" java.io.IOException: (null) entry in command string: null chmod 0700 ...
at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:769)
Solution: You need to set an HADOOP_HOME environment variable. You can either add it as system-wide, or
only for IntelliJ as shown in Setting up and using environment variables in IntelliJ Idea. The name of the environment variable should be
HADOOP_HOME, while its value is the folder path of your Hadoop binary (in this example, the value is
C:\hadoop-2.7.3).
3.2 You may get another exception that says
Exception in thread "main" java.lang.UnsatisfiedLinkError:
org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z
at org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Native Method)
To solve this issue, you need to download the source package of Hadoop from given link in Sec. 1, extract
and copy hadoop-2.7.3-src.tar.gz\hadoop-2.7.3-src\hadoop-common-project\hadoop-common\src
\main\java\org\apache\hadoop\io\nativeio\NativeIO.java to your project, and modify Line 609 (in
function access) from
return access0(path, desiredAccess.accessRight());
to
return true;
What to do?
I'm writing a java application (on Linux OS) which accesses the webcam and display a video on a JPanel. I'm using openCV libraries in order to obtain it (also because I would like to add some image processing code).
I followed this guide to compile the openCV library for Java
and the only way I could make it work was by creating an user library linked to the folder where I have the corresponding jar file.
(I tried to directly import the jar file but I have some runtime exception, so I gave up).
This is my situation.
Now I have a working application (if I execute it from within Eclipse), and I want to export it as a single jar (or something executable outside Eclipse). I tried to achieve this by selecting these options.
The problem is that now I want test if the jar works by executing the following command from terminal (where Untitled.jar is the name of the exported code):
java -jar Untitled.jar
but I receive this error (I bolded the main problem):
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.UnsatisfiedLinkError: no opencv_java331 in
java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at
java.lang.Runtime.loadLibrary0(Runtime.java:870) at
java.lang.System.loadLibrary(System.java:1122) at
myRefreshTest.Main.main(Main.java:8)
opencv_java331 is the name of the .so library generated after building openCV for Java (opencv_java331.so)
I tried several way to export my program, also by selecting the 3rd option in the Eclipse export popup ("Copy required libraries into sub-folder next to the generated JAR) and then executing
java -cp Untitled_lib/opencv-331.jar -jar Untitled.jar
but terminal returns this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no
opencv_java331 in java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at
java.lang.Runtime.loadLibrary0(Runtime.java:870) at
java.lang.System.loadLibrary(System.java:1122) at
myRefreshTest.Main.main(Main.java:8)
So, the problem is clear, it can't find the openCV .so library.
I tried to use also option -Djava.library.path but it is not working (or at least I'm not using it properly)
I'm not a Java expert and I cannot understand how to fix this problem. Does anyone know how to fix this issue?
I use ghost4j GhostScript to manage TIFF and PDF files in a webapp.
I included Ghost4J into my project using Maven and installed Ghostscript into C:\Program Files\gs\... but after this I still get an error:
java.lang.UnsatisfiedLinkError: Unable to load library 'gsdll64'
To solve this, I must place the file gsdll64.dll in working directory (usually c:\eclipse) as proposed here.
Till here everything fine, but when I deploy the app in the integration environment (win7 and tomcat7) I get this exception:
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.ghost4j.GhostscriptLibrary.
I installed Ghostscript into C:\Program Files\gs\... in the host and as in this discussion I wrapped code with try {} catch (Exception e) but does not seem to help.
Any idea where I should place the gsdll64.dll or how to solve the error?
One solution is to add dll to %JAVA_HOME%/jre/bin as it is usually on the PATH.
Alternatively add the directory that contains the dll to PATH since on Windows, java.library.path is initialised from the PATH environment variable.
Check this thread on StackOverflow for reference.
For Tomcat 7, can copy gsdll64.dll to %TOMCAT_HOME%\bin directory or create setenv.bat under %TOMCAT_HOME%\bin directory with the following entry.
set PATH=%PATH%;C:\gs\gs9.18\bin
where C:\gs\gs9.18 is the installed Ghostscript folder. Check Apache Tomcat Native Library installation document on this.
i am using netbeans ide and trying to capture packets using jpcap library. my program used to run correctly before bu suddenly this error
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpcap in java.library.path
is appearing. i have tried ds on my other computer too but in vain ..
i have added jpcap library and before installing i cleared older version completely. have done everythng available .i am seriously in trouble
please help!
Add this to the beginning of your program:
System.out.println(System.getProperty("java.library.path"));
You should get a list of directories. Your jpcap's DLL (or so on UNIX) must be in one of these directories in order for your program to work. If it is not there, then either:
Add the directory containing that DLL/so to your system's PATH (preferred).
Add the DLL/so into one of the directories printed.
I was trying to run the CHARVA Tutorial thru Eclipse after setting up the JAR,
but I receive
Exception in thread "main" java.lang.UnsatisfiedLinkError: no Terminal in java.library.path
in the console. Any clue on how to fix this up?
As Dave said, Charva requires a native library called Terminal to run. As far as I remember, it is included in the binary distribution for Charva.
Eclipse-specific instructions: In your project properties, select Java Build Path, then Libraries. Locate the jar and set the Native library location to the path where the Terminal library is.