[2.0.4] IDE: macOS: problems using OCR features (Tesseract lib missing)

Asked by Ben Dix on 2020-11-29

*********** workaround until 2.0.5 is out ********

- make sure you have Tesseract on your machine
- when using the steps at https://github.com/RaiMan/SikuliX1/wiki/macOS-Linux:-Support-libraries-for-Tess4J-Tesseract-4-OCR you should have a libtesseract.dylib entry in /usr/local/lib

If you want to use the OCR features in the IDE with Jython scripting, you have to put this at the top of your main script:
import java.lang.System as JS
JS.setProperty("jna.library.path", "/usr/local/lib")

After that you can use OCR features in your script and imported scripts


using Sikuli 2.0.4 on Java 11 (Catalina) and having problems with text() OCR in general, cause of the missing link to my lib.
I already found the workaround for a solution, but can't get this to work:


I tried adding the path by using my terminal, as written in the first link:

java -Djna.library.path=</usr/local/lib> MainClass

but it is not working...
could you please provide the correct command line for adding this path to the jna.library.path?
I would be very thankful!


Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

not sure if it is a typo, but bit should read:

java -Djna.library.path=/usr/local/lib MainClass

on top I assume, that a SikuliX jar is on the Java class path by some means.

Ben Dix (bendix80) said : #2

thx for your fast response.
I tried this but got an error:

Fehler: Hauptklasse MainClass konnte nicht gefunden oder geladen werden
Ursache: java.lang.ClassNotFoundException: MainClass

in english:
error, mainclass manilas could not be found or loaded
reason: java.lang.ClassNotFoundException: MainClass

maybe cause of the SikuliX on the java class path?
I am a beginner in python and java...

Help needed 😄
thx a lot!

RaiMan (raimund-hocke) said : #3

no problem, English is always ok ;-)

This is a one-time help, because it's the first advent :-)) (reason: basic Java knowledge - many tutorials on the net)

Suggesting you used my example from #1

java -Djna.library.path=/usr/local/lib -cp <path-to-your-jar-or-folder>:<path-to-sikuli...jar> <name-of-main-class>

the items <...> have to be replaced by the appropriate filenames on your system.

alternatively, if you have your code packed in a jar:

java -Djna.library.path=/usr/local/lib -cp <path-to-sikuli...jar> -jar <path-to-your-jar>

by simply typing java, you get some information about the command line parameters (more and examples in the net)

RaiMan (raimund-hocke) said : #4

ok, if you speak German, then German is ok of course too.

Ben Dix (bendix80) said : #5

Happy first advent 😄
it's fine for me talking in english so the others may also profit of my newbie questions 😄
but thx for that offer...

reading lots of basics about java right now, trying to get it...

I am starting the SikuliIDE using terminal by typing:
java -jar <path-to-sikuli>/sikulixide-2.0.4.jar

still don't understand my <path-to-your-jar-or-folder> and <name-of-main-class>.
what jar or folder are we searching for?
OCR is the main class?

i will go on, trying to find the solution by studying more java ...
but maybe the second advent can allow a hint to what I am searching for 😄


RaiMan (raimund-hocke) said : #6

Are you using scripting in the IDE or are you programming in Java?

To avoid the OCR problem in the IDE:

java -Djna.library.path=/usr/local/lib -jar <path-to-sikuli>/sikulixide-2.0.4.jar

all the other remarks are for programming in Java.

Ben Dix (bendix80) said : #7

Like a very early Christmas Present 😄
thx for that.

I am using the IDE.
Tried to start the IDE with:

java -Djna.library.path=/usr/local/lib -jar /Users/MYNAME/Desktop/Sikulix/sikulixide-2.0.4.jar

but if any OCR commands are part of my script, it redirects me to the GITHUB Tesseract help page again...

I red that you try to fix this with 2.0.5, so I am fine waiting for that release 😄

Don't want to steal your time with my questions!
thank you very much!

RaiMan (raimund-hocke) said : #8

Do you have Homebrew on your machine and did you install Tesseract

brew install tesseract


If yes - In a Terminal with

tesseract --version

you should get something like that:
tesseract 4.1.1
  libgif 5.2.1 : libjpeg 9d : libpng 1.6.37 : libtiff 4.1.0 : zlib 1.2.11 : libwebp 1.1.0 : libopenjp2 2.3.1
 Found AVX2

If you used other means to get Tesseract on your machine, then you have to find out, where libtesseract.dylib is located and use this folder with the -Djna....
 Found AVX
 Found FMA
 Found SSE

RaiMan (raimund-hocke) said : #9

2.0.5 might be under the Christmas tree - but no promises ;-)

Ben Dix (bendix80) said : #10

installed over brew:

tesseract 4.1.1
  libgif 5.2.1 : libjpeg 9d : libpng 1.6.37 : libtiff 4.1.0 : zlib 1.2.11 : libwebp 1.1.0 : libopenjp2 2.3.1
 Found AVX
 Found SSE

in my usr/local/lib is a tesseract.dylib alias.

Shall I try the original path?:

RaiMan (raimund-hocke) said : #11

Ok, thanks for not giving up :-))

I have to apologise for not having tested before.
After I did, I found out, that my suggestion only works with Java programming.

Since with the IDE a separate Java process is started internally, the -D spec from the command line does not get through to the IDE.

Hence you have to do it on the script level.

I have put this workaround at the top of this question.

All the best.

Ben Dix (bendix80) said : #12

I have to thank you for not giving up 😄
now it is working! thx a lot!!!

Greetings and keep healthy 😄

RaiMan (raimund-hocke) said : #13

Same to you :-))