Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniavutil in java.library.path: - javacv

I am getting the following error while adding and testing javaCV to project in intellij in ubuntu 22.04. I hava read the documentation(https://github.com/bytedeco/javacv) but didn't understand what to do extactly. What I have done for adding javaCV to project is,
File -> Project Structure -> Module -> dependencies (+ add dependencies)
then selected javacpp.jar, javacv.jar, opencv.jar and ffmpeg.jar from the 'javacv-platform-1.5.7-bin' folder which I downloaded.
This is the output which I get after running a code:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniavutil in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2434)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:848)
at java.base/java.lang.System.loadLibrary(System.java:2015)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1800)
at org.bytedeco.javacpp.Loader.load(Loader.java:1402)
at org.bytedeco.javacpp.Loader.load(Loader.java:1214)
at org.bytedeco.javacpp.Loader.load(Loader.java:1190)
at org.bytedeco.ffmpeg.global.avutil.<clinit>(avutil.java:14)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:488)
at java.base/java.lang.Class.forName(Class.java:467)
at org.bytedeco.javacpp.Loader.load(Loader.java:1269)
at org.bytedeco.javacpp.Loader.load(Loader.java:1214)
at org.bytedeco.javacpp.Loader.load(Loader.java:1190)
at org.bytedeco.ffmpeg.avformat.Read_packet_Pointer_BytePointer_int.<clinit>(Read_packet_Pointer_BytePointer_int.java:45)
at org.bytedeco.javacv.FFmpegFrameGrabber.<clinit>(FFmpegFrameGrabber.java:362)
at com.cooltrickshome.MovieToImage.convertMovietoJPG(MovieToImage.java:31)
at com.cooltrickshome.MovieToImage.main(MovieToImage.java:25)
Caused by: java.lang.UnsatisfiedLinkError: Could not find jniavutil in class, module, and library paths.
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1767)
... 14 more
Process finished with exit code 1
Can anyone tell the exact steps to follow to add javaCV to the project in intellij ?

I have a similar problem as it failed to find the the library. I ends up build my own ffmpeg, and copying the dylib files in jniLibs, and adding a line like System.loadLibrary("avutil.57") in the static scope.
another way could be setting up the library path:
-Djava.library.path=/Users/xxx/ffmpeg-java-samples/src/main/jniLibs
Since you are in Ubuntu, up to this point, it should be able to fix your issue. However, for the mac, the end result the exception message changes to
tried:'/Users/xxx/ffmpeg-java-samples/src/main/jniLibs/libavutil.57.dylib',
but hitting to another issue: (mach-o file, but is an incompatible
architecture (have (arm64), need (x86_64)))
I am still figuring out the ffmpeg for mac M1 chip part.
after making sure the following jar file, it seems running:
export CLZPATH=$CLZPATH:$JARROOT/org/bytedeco/javacpp/1.5.8/javacpp-1.5.8.jar
export CLZPATH=$CLZPATH:$JARROOT/org/bytedeco/javacpp-presets/ffmpeg/4.1-1.4.4/ffmpeg-4.1-1.4.4.jar
export CLZPATH=$CLZPATH:$JARROOT/org/bytedeco/javacpp-presets/ffmpeg/4.1-1.4.4/ffmpeg-4.1-1.4.4-macosx-x86_64.jar

Related

SpringToolSuite 4 and proper OSGi clean

I have SpringToolSuite 4 installed in macOS 11 "Big Sur" running in aarch64 of Zulu11 OpenJDK 11.0.11+9-LTS . I get this error below when starting up and have added the "-clean" parameter to the two ways I use to start up.
From an Applescript: open /Applications/SpringToolSuite4.app" & " --args -clean
Or from the command line: ./SpringToolSuite4 -clean
It would seem the clean parameter is successfully sent as '-Dosgi.clean="true"' is on the last line below. However, it doesn't seem to help as this is reappearing at every restart.
Are there other ways to do an OSGi clean?
I can't edit the ini-file because macOS will clampdown on this and render the whole installation invalid. Since the clean command seems to get passed, that is likely unnecessary.
Error message:
java.lang.UnsatisfiedLinkError: ~/Library/Caches/JNA/temp/jna13221667715595625418.tmp: dlopen(~/Library/Caches/JNA/temp/jna13221667715595625418.tmp, 1): no suitable image found. Did find:
~/Library/Caches/JNA/temp/jna13221667715595625418.tmp: no matching architecture in universal wrapper
~/Library/Caches/JNA/temp/jna13221667715595625418.tmp: no matching architecture in universal wrapper
~/Library/Caches/JNA/temp/jna13221667715595625418.tmp: dlopen(~/Library/Caches/JNA/temp/jna13221667715595625418.tmp, 1): no suitable image found. Did find:
~/Library/Caches/JNA/temp/jna13221667715595625418.tmp: no matching architecture in universal wrapper
~/Library/Caches/JNA/temp/jna13221667715595625418.tmp: no matching architecture in universal wrapper
java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
java.base/java.lang.Runtime.load0(Runtime.java:768)
java.base/java.lang.System.load(System.java:1837)
com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1018)
com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:988)
com.sun.jna.Native.(Native.java:195)
com.github.dockerjava.zerodep.UnixDomainSocket.(UnixDomainSocket.java:80)
com.github.dockerjava.zerodep.ApacheDockerHttpClientImpl$2.createSocket(ApacheDockerHttpClientImpl.java:124)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:125)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:409)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:164)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:174)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:135)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:165)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:93)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:116)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:128)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:178)
com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:67)
com.github.dockerjava.zerodep.ApacheDockerHttpClientImpl.execute(ApacheDockerHttpClientImpl.java:157)
com.github.dockerjava.zerodep.ZerodepDockerHttpClient.execute(ZerodepDockerHttpClient.java:8)
com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:228)
com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:202)
com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:75)
com.github.dockerjava.core.exec.InfoCmdExec.exec(InfoCmdExec.java:24)
com.github.dockerjava.core.exec.InfoCmdExec.exec(InfoCmdExec.java:14)
com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35)
org.springframework.ide.eclipse.boot.dash.docker.runtarget.DockerRunTarget.connect(DockerRunTarget.java:130)
org.springframework.ide.eclipse.boot.dash.cloudfoundry.RemoteBootDashModel.lambda$2(RemoteBootDashModel.java:77)
org.springframework.ide.eclipse.boot.dash.model.remote.RefreshStateTracker.call(RefreshStateTracker.java:80)
org.springframework.ide.eclipse.boot.dash.model.remote.RefreshStateTracker.lambda$3(RefreshStateTracker.java:123)
org.springsource.ide.eclipse.commons.frameworks.core.util.JobUtil$6.run(JobUtil.java:193)
org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
-Dosgi.clean="true"
The issue mentioned above is this: https://github.com/spring-projects/sts4/issues/684
It is not related to OSGi, so -clean doesn't help here. The fix will be part of STS 4.12.1 release, but you could grab a nightly CI build to get the fix right away from here: http://dist.springsource.com/snapshot/STS4/nightly-distributions.html
On a related note: Once you started STS at least one you should be able to modify the .ini file without issues. If macOS still complains about it, you can remove the quarantine flag from the app:
sudo xattr -r -d com.apple.quarantine SpringToolSuite4.app
This will avoid the error message and let you start your STS4 install even after editing the content.

Building RXTX with --disable-locks

I need to build RXTX (http://rxtx.qbang.org/wiki/index.php/Main_Page) for a 64 bit platform with --disable-locks. ( the target platform is a Ubuntu Snappy platform so there is a problem with the permissions and lock files).
The .configure --disable-locks and make seemed to run ok.
I got a new .jar file and librxtxSerial.so as a result.
However when I installed them, I get the following error :
java.lang.UnsatisfiedLinkError: gnu.io.RXTXCommDriver.nativeGetVersion()Ljava/lang/String; thrown while loading gnu.io.RXTXCommDriver
java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver thrown while loading gnu.io.RXTXCommDriver
Is there something else I need to do?
Are there other object files I need to copy over.
Thanks in advance.
I solved the problem myself.
The problem was that the configure script was not expecting a java version higher than 1.5 as shown here in t he extract :
case $JAVA_VERSION in
1.2*|1.3*|1.4*|1.5*)
#fix_parameters $JPATH/jre/lib/javax.comm.properties
CLASSPATH=".:\$(TOP):\$(TOP)/src:"find $JPATH/ -name RXTXcomm.jar |head -n1
RXTX_PATH="\$(JPATH)/jre/lib/\$(OS_ARCH)"
JHOME=$JPATH/"jre/lib/ext"
So the paths were not being set up correctly for me.
I changed it to
case $JAVA_VERSION in
1.2*|1.3*|1.4*|1.5*|1.7*)
Then it worked ok.

Running Typesafe Activator 1.2.10 on OSX Maverick error

I have just downloaded Typesafe Activator 1.2.10-minimal on Mac OSX Maverick. When I try to run it using any command, I get the following error:
java.lang.UnsatisfiedLinkError: /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/lwawt/liblwawt.dylib: dlopen(/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/lwawt/liblwawt.dylib, 1): Library not loaded: #rpath/libosxapp.dylib
Referenced from: /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/lwawt/liblwawt.dylib
Reason: image not found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1851)
at java.lang.Runtime.load0(Runtime.java:795)
at java.lang.System.load(System.java:1062)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1872)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:67)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:47)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1653)
at java.awt.Toolkit.<clinit>(Toolkit.java:1682)
at java.awt.Desktop.isDesktopSupported(Desktop.java:169)
at activator.ActivatorLauncher.openDocs(ActivatorLauncher.scala:55)
at activator.ActivatorLauncher.displayHelp(ActivatorLauncher.scala:72)
at activator.ActivatorLauncher.run(ActivatorLauncher.scala:32)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:129)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:36)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:19)
at xsbt.boot.Boot$.runImpl(Boot.scala:44)
at xsbt.boot.Boot$.main(Boot.scala:20)
at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.lang.UnsatisfiedLinkError: /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/lwawt/liblwawt.dylib: dlopen(/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/lwawt/liblwawt.dylib, 1): Library not loaded: #rpath/libosxapp.dylib
Referenced from: /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/lwawt/liblwawt.dylib
Reason: image not found
What could be wrong?
Thanks,
Suriyanto
Copying libosxapp.dylib from /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib to /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/lwawt solved the issue for me. Seems like #rpath looks in only lwawt folder, not in lib folder. Issue had happened to me after installing jdk7 after jdk8.
This does not look like a Scala- or Activator-specific problem, but rather like a problem with your JDK. It is looking for libosxapp.dylib on the run-path search paths, but doesn't find it.
That most likely means that either your JDK installation is broken, or there is some problem with your environment settings (I'm just guessing here, but I think something like DYLD_LIBRARY_PATH might have an impact).
Does /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/libosxapp.dylib exist? If not, that's the problem. You might want to reinstall your JDK then.
Does everything else run fine on that JDK?
Have you tried it with another JDK, e.g. Java 8 (not that Activator would require Java 8, but that would be an easy way to try it on another JDK).

Eclipse still thinks I have RVM installed, but I don't

I'm using Eclim to get auto-completion for Java, Ruby, etc in Vim. It starts an instance of Eclipse. Eclipse still thinks I have RVM installed for some reason (I use rbenv now). Any idea how I should get rid of this configuration problem or work-around this error?
2014-06-22 22:43:10,123 INFO [org.eclim.plugin.jdt.PluginResources] Setting 'JRE_SRC' to '/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/src.zip'
org.eclipse.core.runtime.CoreException: Exception occurred executing command line.
at org.eclipse.debug.core.DebugPlugin.exec(DebugPlugin.java:875)
at org.eclipse.dltk.internal.launching.execution.LocalExecEnvironment.exec(LocalExecEnvironment.java:72)
at org.eclipse.dltk.launching.ScriptLaunchUtil.runScriptWithInterpreter(ScriptLaunchUtil.java:85)
at org.eclipse.dltk.ruby.internal.launching.RubyGenericInstall$BuiltinsHelper.generateLines(RubyGenericInstall.java:70)
at org.eclipse.dltk.ruby.internal.launching.RubyGenericInstall$BuiltinsHelper.load(RubyGenericInstall.java:171)
at org.eclipse.dltk.ruby.internal.launching.RubyGenericInstall$BuiltinsHelper.getSources(RubyGenericInstall.java:144)
at org.eclipse.dltk.ruby.internal.launching.RubyGenericInstall.getBuiltinModules(RubyGenericInstall.java:246)
at org.eclipse.dltk.internal.core.BuiltinProjectFragment.isSupported(BuiltinProjectFragment.java:97)
at org.eclipse.dltk.internal.core.ScriptProject.computeProjectFragments(ScriptProject.java:673)
at org.eclipse.dltk.internal.core.ScriptProject.computeProjectFragments(ScriptProject.java:605)
at org.eclipse.dltk.internal.core.ScriptProject.computeProjectFragments(ScriptProject.java:565)
at org.eclipse.dltk.internal.core.ScriptProject.getAllProjectFragments(ScriptProject.java:2921)
at org.eclipse.dltk.internal.core.ScriptProject.getAllProjectFragments(ScriptProject.java:2915)
at org.eclipse.dltk.core.search.indexing.core.ProjectRequest.run(ProjectRequest.java:67)
at org.eclipse.dltk.core.search.indexing.AbstractJob.execute(AbstractJob.java:76)
at org.eclipse.dltk.internal.core.search.processing.JobManager.run(JobManager.java:467)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Cannot run program "/Users/ivan/.rvm/rubies/ruby-2.0.0-p195/bin/ruby" (in directory "/var/folders/nh/07hs5mmj0hs7fdq3181dwpbc0000gn/T/dltk60850.tmp/scripts"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
at java.lang.Runtime.exec(Runtime.java:620)
at org.eclipse.debug.core.DebugPlugin.exec(DebugPlugin.java:871)
... 16 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:185)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
... 18 more
Eclim uses .buildpath for projects to set configurations. Check to make sure there aren't any remnant rvm / ruby configuration files left in any of your current active/existing projects in Eclipse.
Eclim uses .buildpath files to set the configuration for each project. There was an old project on my hard drive that had a reference to an rvm ruby in the text of the .buildpath file. It can be really hard to track down all old projects without the use of a file find utility such as locate. For this particular issue, I used locate buildpath | xargs grep rvm to search each buildpath file for the string rvm. Because the stack trace does not point to the project or build path file, only by doing this kind of search was I able to resolve the issue.

EmguCV 'Emgu.CV.CvInvoke' Exception

I have installed EmguCV 2.4.2.1777. I have a 32-bit windows 7 so I installed it using the installer. Now I am trying to write a simple code to capture a webcam's video in a window in C#.
The problem is after during execution I am getting the following famous error:
A first chance exception of type 'System.DllNotFoundException' occurred in Emgu.CV.dll
A first chance exception of type 'System.TypeInitializationException' occurred in Emgu.CV.dll
An unhandled exception of type 'System.TypeInitializationException' occurred in Emgu.CV.dll
The file Emgu.CV.dll is present in the folder. I don't understand why its giving that error.
I tried all the checks which are suggested by fellow stackoverflow users and also many other references:
1) Installed MSVCR: MSVCRT 10.0 SP1 x86
2) copied the OpenCV dlls to the execution directory
3) I also have a 32-bit OS. So that also should'nt be an issue.
But when I checked for dependencies, I faced a problem:
I used DependecyWalker to open cvextern.dll and found the following dependencies missing:
NVCUDA.DLL
API-MS-WIN-CORE-COM-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-0.DLL
DCOMP.DLL
IESHIMS.DLL
It also gave the following:
Error: At least one required implicit or forwarded dependency was not found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
Please help me out with the exception. Thanks in advance.
I copied all the dll files from C:\Emgu\emgucv-windows-universal-gpu 2.4.9.1847\bin\x86 to a folder called includes in my project and updated the "Copy To Output Directory" Option for these DLLs to "Copy Always" and it got rid of this issue.

Resources