Cannot load the JNotify native library (no jnotify in java.library.path) - java

When I try to run any play project, I'm getting the following warning, and it seems to be making my projects run considerably slower than normal:
Cannot load the JNotify native library (no jnotify in java.library.path)
Play will check file changes for each request, so expect degraded reloading performance.
I found this question, that seems to have solved the issue for Windows users, but I haven't found a solution for Linux machines
I tried copying the .jar and .so downloaded from here into /usr/lib/jvm/jdk1.8.0_212/bin/ with no success
Also, I noticed that in my play directory (~/play/repository/local/net.contentobjects.jnotify/jnotify/0.94/jars) there is a jnotify.jar, so I'm not sure why it is not using that one
I'm using Play v2.2.4, on Ubuntu 20.04 64 bits
After extracting the .so from jnotify.jar, the output of the ldd libjnotify.so command was:
linux-vdso.so.1 (0x00007ffd4c3cd000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f94bbed5000)
/lib64/ld-linux-x86-64.so.2 (0x00007f94bc2df000)
It doesn't seem to list any unresolved libraries (though I'm not sure how to interpret that output). libc.so.6 and ld-linux-x86-64.so.2 exist in the directories listed, and I'm not sure where it looks for linux-vdso.so.1
Any help is appreciated!

I'll describe how it was solved for the future generations:
First, download JNotify here and unzip it
Then type java -XshowSettings:properties into the terminal, and check the java.library.path property.
In my case, the first path listed here was /usr/java/packages/lib/amd64
Finally, move the unzipped file 64-bit Linux/libjnotify.so to the directory in java.library.path (in my case, /usr/java/packages/lib/amd64)
After restarting play, it worked
Thanks again #cbley!

Related

Encountered error setting up plugins for Minecraft Nukkitx server on Raspberry Pi

RPI 2B, running Debian/Jessie, with java version 1.8.0_65.
Downloaded latest nukkitx from https://nukkitx.com.
Followed installation instructions at https://github.com/IntellectualCrafters/PlotSquared/wiki/Installation.
Plugins I have installed:
Plot Squared 18.07.21-aaa7088-2022
FastAsyncWorldEdit 18.07.21-a00345f-1159-20.4.0
DbLib 0.2.3
Error I am encountering:
java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open(Ljava/lang/String;I)V
Stack trace: https://pastebin.com/C3DrUm0Q.
Full server log: https://pastebin.com/2iuvQmbC.
As you can see, it says that PlotSquared has been loaded, but none of the plot commands are available. It just says unknown command when I type it. I have tried several different versions of all of the plugins, and a couple previous versions of nukkitx, all have the same problem. I'm thinking its something about my device, but I'm still pretty new to Linux and am not sure what to try next. Any suggestions would be amazing!
EDIT: I download the driver from https://github.com/xerial/sqlite-jdbc, and added it to the class path when calling the nukkitx jar to start the server. This didn't fix the problem. Here is the .sh file to start the nukkit jar:
#!/bin/sh
echo $USER
java -Xms1G -Xmx1G -cp ".;sqlite-jdbc-3.23.1.jar" -jar nukkit-1.0-SNAPSHOT.jar
I figured it out! For whatever reason, the JbLib sqlite driver apparently wasn't working. The solution was to remove JbLib (jar and folder) from the plugins folder, change the start.sh file (which I created according to the installation instructions) to use a classpath command instead of a jar command, add the xerial sqlite driver to the class path, and specify the Main Nukkit class to execute, like so:
java -classpath nukkit-1.0-SNAPSHOT.jar:sqlite-jdbc-3.23.1.jar cn.nukkit.Nukkit

java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.createDirectoryWithMode0

I cannot solve this exception, I've read the hadoop docu and all related stackoverflow questions that I could find.
My fileSystem.mkdirs(***) throws:
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.createDirectoryWithMode0(Ljava/lang/String;I)V
at org.apache.hadoop.io.nativeio.NativeIO$Windows.createDirectoryWithMode0(Native Method)
at org.apache.hadoop.io.nativeio.NativeIO$Windows.createDirectoryWithMode(NativeIO.java:524)
at org.apache.hadoop.fs.RawLocalFileSystem.mkOneDirWithMode(RawLocalFileSystem.java:465)
at org.apache.hadoop.fs.RawLocalFileSystem.mkdirsWithOptionalPermission(RawLocalFileSystem.java:518)
at org.apache.hadoop.fs.RawLocalFileSystem.mkdirs(RawLocalFileSystem.java:496)
at org.apache.hadoop.fs.FilterFileSystem.mkdirs(FilterFileSystem.java:316)
...
I am including the following dependencies in my app (via maven pom.xml), all in version 2.6.0-cdh5.13.0: hadoop-common, hadoop-hdfs, hadoop-client, hadoop-minicluster
My filesystem variable is a valid (hadoop-common) FileSystem (org.apache.hadoop.fs.FileSystem).
I downloaded the hadoop files from https://github.com/steveloughran/winutils/tree/master/hadoop-2.6.0/bin.
I stored the winutils.exe and all the other files from in version 2.6.0 to my local file system under C:\Temp\hadoop\bin.
I added the path variable HADOOP_HOME with C:\Temp\hadoop (yes, not the path to the bin directory).
The fallback is not used ("using builtin-java classes"), I am getting:
145 [main] DEBUG org.apache.hadoop.util.NativeCodeLoader - Trying to load the custom-built native-hadoop library...
147 [main] DEBUG org.apache.hadoop.util.NativeCodeLoader - Loaded the native-hadoop library
(See https://hadoop.apache.org/docs/r2.6.0/hadoop-project-dist/hadoop-common/NativeLibraries.html)
I understood, that this exception can be caused by a hadoop version mismatch, but I checked that the imported hadoop matches the hadoop I stored locally, version wise.
I am working on a Windows 10 x64 system and in IntelliJ.
Anybody has an idea, what I could check or even, what I am doing wrong?
UPDATE:
I run my main with the following VM options
-Dhadoop.home.dir=C:/Temp/hadoop
-Djava.library.path=C:/Temp/hadoop/bin
Without specifying the lib path, I get:
org.apache.hadoop.util.NativeCodeLoader - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
To me setting VM Argument -Djava.library.path=C:\devTools\winutils-master\hadoop-3.0.0
resolved the issue.
The reason for this exception was:
I am importing 2.6.0-cdh5.13.0 via my maven pom, but I downloaded the pre-built files in version 2.6.0. Those are missing the changes made in the cdh5.13.0 variant (CDH is Cloudera’s platform that includes the Hadoop ecosystem). Hence, the versions are indeed in conflict.
If I import hadoop-common, hadoop-hdfs, hadoop-client like 2.6.0 instead of like 2.6.0-cdh5.13.0, the exception disappears (and I don't even need to set the VM options).
See http://archive-primary.cloudera.com/cdh5/cdh/5/hadoop-2.6.0-cdh5.13.0/hadoop-project-dist/hadoop-common/NativeLibraries.html
Check your java version. If java is 32bits version, you need uninstall and re-install with 64 bits version for hadoop.
Check command:
java -d32 -version;(no error, if 32 version)
java -d64 -version;(no error, if 64 version)
Download hadoop.dll and winutils.exe files from hadoop-3.0.0 and got resolve
https://github.com/steveloughran/winutils/tree/master/hadoop-3.0.0/bin
In my case, the issue was that i had hadoop.dll in system32,
if you run hadoop on windows and he finds hadoop.dll in System32 or in your HADOOP_HOME\bin then he consider that it's a cluster, the probleme is that clusters are not compatible with windows, so it fails.
Solution delete hadoop.dll from System32 and HADOOP_HOME\bin
see : Full answer
Had this issue and it turned out HADOOP_HOME was set to a 2.6.4 version folder. Updated it to a 3.0.0 folder and it worked. It seems in general either you have to update it on the calling end with -Djava.library.path or in your environment settings to 3.0.0.
For the environment variable, HADOOP_HOME is a system environment variable you can access via the command
rundll32.exe sysdm.cpl, EditEnvironmentVariables
This can be entered into ⊞ + R (windows key + R) followed by ctrl + shift and enter, or by opening powershell or cmd as admin.
From here I edited the system environment variable HADOOP_HOME to the 3.0.0 folder, and I updated the system PATH to HADOOP_HOME/bin. Be sure there are no conflicts in your user variables, such as in PATH.
After that, any terminal or program calling Spark should be restarted and checked to make sure it loaded the new environment variables.
I am having the same issue with writing parquet files in spark. Downloading the hadoop.dll and winutils.exe files from hadoop-3.0.0 and moving hadoop.dll to C:\Windows\System32 folder and moving winutils.exe to C:\hadoop\bin folder solved my problem.
Thanks Shailendra Singh for sharing the above link

Tess4j unsatisfied link error on mac OS X

Hey i am trying to use tess4j for tesseract and having this issue for eclipse on mac osx .
My tesseract is working fine from terminal but trying to run tess4j through tesseract throws me an error .
java.lang.UnsatisfiedLinkError: Unable to load library 'tesseract': Native library (darwin/libtesseract.dylib)
i do have tessetact dylib and its named libtesseract.dylib in my opt/local/lib which i installed using macport .
Thanks for your help
I know it's an old post. I had this problem too recently when I tried to use Tess4J. However, I managed to find a way around it. I've written a post about it http://www.microshell.com/programming/java/performing-optical-character-recognition-in-java/
In short, the problem is because tess4j-2.0.0.jar doesn't include MacOS library. So I just modified the maven cached jar on mine by doing these steps:
cd /Users/user/.m2/repository/net/sourceforge/tess4j/tess4j/2.0.0 (adjust the directory where your tess4j JAR file resides)
mkdir darwin
jar uf tess4j-2.0.0.jar darwin
cp /opt/local/lib/libtesseract.3.dylib darwin/libtesseract.dylib
jar uf tess4j-2.0.0.jar darwin/libtesseract.dylib
jar tf tess4j-2.0.0.jar (to verify that the file is included)
I was then able to run my Java program after I modify the tess4j-2.0.0.jar file. Below is my MacOS version.
user#laptop:~$ uname -a
Darwin Maresas-MacBook-Pro.local 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
I had a very similar issue with Ghost4j, i.e.
InvocationTargetException: Unable to load library 'gs': Native library (darwin/libgs.dylib) not found in resource path
Instead of modifying jar files, point jna to the appropriate lib path by setting jna.library.path. In Eclipse, you need to set the system property in run configurations - SO answer for this here - https://stackoverflow.com/a/862405/2163229
If you're using Maven exec:
mvn -Djna.library.path=/opt/local/lib/ exec:java -Dexec.mainClass="foo.bar.NativeThingy"
or
export MAVEN_OPTS="-Djna.library.path=/opt/local/lib/" && mvn exec:java -Dexec.mainClass="foo.bar.NativeThingy"
Obviously, set the path to wherever your libs are installed. In my case, I ran $ locate libgs.dylib and found the above path.
References:
https://jna.java.net/javadoc/com/sun/jna/NativeLibrary.html
You need install the tesseract lib on your Mac.
brew install tesseract --with-all-languages
#maresa after a few years your comment helped me, thanks a lot :) A bit different paths, maybe it'll help someone:
cd /Users/username/.m2/repository/net/sourceforge/tess4j/tess4j/4.5.4/
mkdir darwin
jar uf tess4j-4.5.4.jar darwin/
brew info tesseract (here you can find path to libtesseract.4.dylib)
cp /usr/local/Cellar/tesseract/4.1.1/lib/libtesseract.4.dylib darwin/libtesseract.dylib
jar uf tess4j-4.5.4.jar darwin/libtesseract.dylib
jar tf tess4j-4.5.4.jar
MacOS Catalina - 10.15.3
Make sure you use libtesseract.dylib of Tesseract 3.02 version. Check out this post on Tesseract Forum.
This is exactly what I was after today, so thanks for the Q&A above. As one additional step beyond what maresa mentioned, I ran into this error after fixing the one you asked about:
java.lang.UnsatisfiedLinkError: dlopen(/var/folders/sq/rh89_ntd7jqdlv9__25zj9dr0000gp/T/jna--913086793/jna8800789057827590119.tmp, 9): Library not loaded: /usr/local/lib/libjpeg.8.dylib
Referenced from: /usr/local/lib/liblept.4.dylib
Reason: image not found
So to fix this I needed to set up a symlink for libjpeg.8.dylib:
ln -s /usr/local/Cellar/jpeg/8d/lib/libjpeg.8.dylib /usr/local/lib/libjpeg.8.dylib
Not sure if there is a way to do this without the symlink (i.e. package it in the jar), but I hope this helps anyone else who is looking at this post.
Based on maresa's answer above, which works perfectly, I wrote a library that will make it easy to patch the tess4j.jar file with the appropriate C library from tesseract. You can get it here.

How to solve this JNA issue?

I have application which use JNA and gets the audio and video. It works in my Linux box. But when i am testing it in Windows. It just never working. Because i am still learning, i will appreciate your suggestion how to fix it, i already spent few days and weeks only to work it out, but just dont get this why JAVA does not work simply, its a cross platform. Why should it require again System path or etc configuration.
I am totally lost now, why it works in Linux and it does not work in Windows XP ? How can i run it then ?
Inside the lib direcotry i have my JNA and Audio libraries.
C:\Documents and Settings\test\Desktop\test>dir
Volume in drive C has no label.
Volume Serial Number is 680F-0963
Directory of C:\Documents and Settings\test\Desktop\test
19/12/2010 22:09 <DIR> .
19/12/2010 22:09 <DIR> ..
19/12/2010 22:09 51.791 Audio.jar
19/12/2010 22:09 <DIR> lib
1 File(s) 51.791 bytes
3 Dir(s) 487.002.112 bytes free
Now trying to run Audio.jar, gets Fail 1:
C:\Documents and Settings\test\Desktop\test>java -Djava.library.path=~/jni -jar
Audio.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load librar
y gstreamer-0.10
at org.gstreamer.lowlevel.GNative.loadWin32Library(GNative.java:83)
at org.gstreamer.lowlevel.GNative.loadLibrary(GNative.java:43)
at org.gstreamer.lowlevel.GstNative.load(GstNative.java:42)
at org.gstreamer.lowlevel.GstNative.load(GstNative.java:39)
at org.gstreamer.Gst.<clinit>(Gst.java:59)
at video.MyVideo.simpletest(MyVideo.java:31)
at sipphone.MainApplet.run(MainApplet.java:58)
at sipphone.MainApplet.main(MainApplet.java:43)
Fail 2:
C:\Documents and Settings\test\Desktop\test>java -Djna.library.path=. -jar Audio
.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load librar
y gstreamer-0.10
at org.gstreamer.lowlevel.GNative.loadWin32Library(GNative.java:83)
at org.gstreamer.lowlevel.GNative.loadLibrary(GNative.java:43)
at org.gstreamer.lowlevel.GstNative.load(GstNative.java:42)
at org.gstreamer.lowlevel.GstNative.load(GstNative.java:39)
at org.gstreamer.Gst.<clinit>(Gst.java:59)
at video.MyVideo.simpletest(MyVideo.java:31)
at sipphone.MainApplet.run(MainApplet.java:58)
at sipphone.MainApplet.main(MainApplet.java:43)
You'll need to have the DLL installed, or at least in your JNA library path as others have pointed out.
It does add an extra dependency on Windows. It would be an extra dependency on Linux but gstreamer is preinstalled by your distribution. I ran into this same problem when I was making something to use a USB port from Java.
The only solution I know of to avoid the DLL would be to have a second version of the code you could call on Windows that would only use Win32 stuff (i.e. stuff that ships with Windows) but that would be a very large undertaking.
trying to run mediarenderer from cling package, I had the same error on windows xp.
i got the right libgstreamer-0.10.so from package GStreamer-WinBuilds-GPL-x86-Beta04-0.10.7.msi found in https://code.google.com/archive/p/ossbuild/downloads
once installed (environment variables PATH (for dependencies) and OSSBUILD_GSTREAMER_DIR set),
in a prompt, I was finally able to run mediarenderer using the following syntax to introduce lib's path :
Z:\Downloads\cling-distribution-2.1.0\cling-distribution-2.1.0\mediarenderer\target>java -Djna.library.path="C:\Program Files\OSSBuild\GStreamer\v0.10.7\bin" -jar cling-mediarenderer-2.1.0-standalone.jar
hope this helps as a starting point !
For Fail 1: I don't believe that the ~/ syntax will work on Windows. Try %HOME%\ instead. The tilde expansion happens in Bash, so things are a bit different in Windows.
For Fail 2: It doesn't look like the .dll is in your test directory, and you're setting the jna.library.path to ..
If the .dll's are in your lib directory, then shouldn't the paths be set to that directory, instead of ~/jni and .?

UnstatisfiedLinkError while trying to use jepp in windows

I am new to java.I have written some python scripts and need to run them from java as desired by my mentor(these scripts are to be deployed on a server).So I have installed Jepp on my windows xp.However when I run
C:\Program Files\Jepp>java -classpath jep.jar jep.Run console.py
I get
java.lang.UnsatisfiedLinkError: C:\WINDOWS\system32\jep.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1728)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at jep.Jep.<clinit>(Jep.java:136)
at jep.Run.run(Run.java:54)
at jep.Run.main(Run.java:153)
I have included the system32 folder containing jep.dll and the Program Files\jepp folder in PATH env. variable but still it is showing the same error.Are there any other directories that need to be included in the PATH variable?
Also in the readme file in jepp dir. for installation,it is given:
Also, you'll likely need to add -Djava.library.path='path to
Release folder' for testing. Or copy and register the DLL in the
System directory.
The jep.dll is already present in system32 directory.What other DLL might have been referred to here.
Ive also tried
C:\Program Files\Jepp>java -classpath jep.jar jep.Run console.py -Djava.library.path='C:\Program Files\Jepp'
but it still gives the same UnsatisfiedLinkError :(
Am I wrong in adding the -Djava.library.path command as in above or is it supposed to be added somewhere else?
I am so confused and getting all kinds of doubts as i've been struggling with this for the past 2 days :( .Even the online documentation is not so detailed and helpful.I would really appreciate any suggestions regarding this....
thanks in advance!

Categories