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 had a very similar issue with Ghost4j, i.e.
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/2163229If you're using Maven exec:
or
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
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.You need install the tesseract lib on your Mac.
brew install tesseract --with-all-languages
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:
So to fix this I needed to set up a symlink for 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.