Could not initialize Finder class (Sikuli X)

Asked by Mark Teixeira

I've been running Jython unit tests with Pydev in Eclipse. After upgrading to Sikuli X, I'm now getting this error:

Finding files...
['C:\\Users\\Adam\\eclipseworkspace\\VyewUnitTests\\FFSuiteAll.py'] ... done
Traceback (most recent call last):
  File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\runfiles.py", line 342, in _PydevTestRunner__get_module_from_str
    mod = __import__(modname)
  File "C:\Users\Adam\eclipseworkspace\VyewUnitTests\FFSuiteAll.py", line 2, in <module>
    from sikuli.Sikuli import *
  File "C:\Program Files (x86)\Sikuli X\sikuli-script.jar\Lib\sikuli\Sikuli.py", line 18, in <module>
    from org.sikuli.script import Finder
NoClassDefFoundError: java.lang.NoClassDefFoundError: Could not initialize class org.sikuli.script.Finder
ERROR: Module: FFSuiteAll could not be imported.

I suspect I've got some path screwed up or some file misplaced because of the upgrade. I had everything set up using the ideas here: https://answers.launchpad.net/sikuli/+question/108782

Help!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

The answer you refer to is a bit out of date and too confusing, when using Pydev within Eclipse.

... contained in path specifications later on have to be adjusted to your situation

The following approach works and is the base for every usage of standalone sikuli-script.jar in Windows with Jython:
- make sure, the native dll's are found (Sikuli installation directory libs and ...Java\jre6\bin)
- have sikuli-script.jar in the Java class-path (in the Sikuli installation directory)
- have the folder Lib contained in sikuli-script.jar in the Python path
- before saying from sikuli.Sikuli import * to initialize Sikuli

1. remove everything that points to something related to 10.2 (%PATH% and other environment settings like Java Class Path or Jytho/Python path's), Eclipse global Settings, Project settings in Pydev - Pythonpath)

2. In Windows system settings -> advanced -> environment settings make sure the following entries are included in PATH:
...path to your Sikuli X folder\libs
...path to your Java\jre6\bin
these entries are needed for Sikuli to find the native libraries (dll's)

3. unjar the sikuli-script.jar to a directory of your choice. You can use the jar utility located in ...Java\jdk...\bin as follows after going to the target directory:
...Java\jdk...\bin\jar.exe -xf ...path to your Sikuli X folder\siculi-script.jar

this new directory (to find the Java classes) and the contained directory Lib (to find the Python stuff) both have to be in a projects external libraries.

To unjar the sikuli-script.jar is not necessary, if you succeed in getting the entry
...path to your Sikuli X folder\siculi-script.jar\Lib
into the python sys.path before running the script (I did not find a way to add it using the features of the Pydev settings pane) (on Windows this is possible with Netbeans)

I did not check the many other possibilities to use Java and/or Jython related environment variables or general settings in Eclipse (not my focus, I am using NetBeans).

Revision history for this message
Mark Teixeira (m-lp-ql-m) said :
#2

I've gone through this 3 times just to make sure I've not missed anything, to no avail. I still get the error "NoClassDefFoundError: java.lang.NoClassDefFoundError: Could not initialize class org.sikuli.script.Finder"

In my "C:\Program Files (x86)\Sikuli X\sikuli-script\org\sikuli\script" folder, I do see "Finder.class"
("C:\Program Files (x86)\Sikuli X\sikuli-script\" being the folder where I un-jar'ed sikuli-script.jar per your instructions.)

I assume that in "C:\Program Files (x86)\Sikuli X\sikuli-script\Lib\sikuli\Sikuli.py", the import statements
   from org.sikuli.script import Region as JRegion
   from org.sikuli.script import UnionScreen
are being correctly imported. So why would the script die at Finder?

Could this have anything to do with my previous problem of being unable to run Sikuli-IDE.exe because of a mixed 32- and 64-bit java environment? (https://answers.launchpad.net/sikuli/+question/139306)

Revision history for this message
RaiMan (raimund-hocke) said :
#3

At least you have to make sure, that the 32-Bit JRE is available and used together with Sikuli.

Revision history for this message
Mark Teixeira (m-lp-ql-m) said :
#4

I uninstalled my 64-bit Java JRE and JDKs, my 64-bit Eclipse, and installed the 32-bit Eclipse-- seems to be working OK so far!

Thanks, RaiMan!

Revision history for this message
Mark Teixeira (m-lp-ql-m) said :
#5

Thanks RaiMan, that solved my question.