Yet another java.lang.UnsatisfiedLinkError

Asked by Andrew Munro

I have an java.lang.UnsatisfiedLinkError using only windows XP machines.

My current setup is a test suite setup on an interactive drive. I have both sikuli installed locally and on the interactive share. The batch file works fine on windows 7 64bit, but not on windows XP 32bit.

I did have my batch files all working correctly until I implemented JDBC server connection which changed the way I execute sikuli ( I know execute using the class path).

My current .bat file:

@echo off

PATH=%PATH%;Sikuli-X-1.0rc3\Sikuli-IDE\libs
set JAVA_EXE="java"

if defined PROGRAMFILES(X86) set JAVA_EXE="%PROGRAMFILES(X86)%\Java\jre6\bin\java.exe"
%JAVA_EXE% -Xms64M -Xmx512M -cp "mysql-jdbc.jar;Sikuli-X-1.0rc3\Sikuli-IDE\sikuli-script.jar" org.sikuli.script.SikuliScript run_suite.sikuli

The error:

java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: C:\Program Files\Sikuli X\libs\Win32Util.dll: Can't find dependent libraries

What is strange is that I have put that exact path (copy and paste) into windows explorer and it found the .dll fine. Im starting to think it's some sort of weird permission error due to it being executed from the network drive. I also put my sikuli lib directory relative to the current drive in the path but it still uses c: to find them.

to clarify, I have two directories it can find the dlls:

C:\Program Files\Sikuli X\libs
Sikuli-X-1.0rc3\Sikuli-IDE\libs < ---- in the working directory

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
RaiMan (raimund-hocke) said :
#1

What about the path entry ???
path-to-java/jre6/bin

so that Win32Util.dll can find the special AWT libraries

Revision history for this message
Andrew Munro (andrew-munro) said :
#2

Sorry I don't follow...my java is in environment variables anyway and only 32bit is installed.

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

I do not really understand your approach.

You have Sikuli installed in its standard location on C:
So why do you need it additionally on the share (BTW: what is an "interactive drive"? usb-stick or so?) ?

--- my java is in environment variables anyway
what does that mean?
post your path to make it clear.

You might additionally set env var SIKULI_HOME - might help.

Revision history for this message
Andrew Munro (andrew-munro) said :
#4

Sorry, interactive drive is a network drive mapped to my computer (effectively a removable hdd / usb-stick).

 I had sikuli installed in this device (the network drive) because it was having issues accessing the lib files from another drive (e.g I run a script on drive D: and it cannot access sikuli files on drive C, this seems to only be present in Windows XP.). It was all working fine and using the .dlls located in my network drive until I modified the bat to use the classpath instead of jar.

My path variable set in Windows Environment Variables is:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\Program Files\Sikuli X\libs;c:Program Files\Java\jre6\bin;C:\Program Files\MySQL\MySQL Server 5.5\bin;I:\QA\sikuli\Sikuli-X-1.0rc3\Sikuli-IDE\libs

My SIKULI_HOME in Windows Environment Variables is:

I:\QA\sikuli\Sikuli-X-1.0rc3\Sikuli-IDE\libs

I execute sikuli with the following command:

%JAVA_EXE% -Xms64M -Xmx512M -cp "mysql-jdbc.jar;Sikuli-X-1.0rc3\Sikuli-IDE\sikuli-script.jar" org.sikuli.script.SikuliScript run_suite.sikuli

However, it still searches in my C:\Program Files\Sikuli X\libs\ folder and as a result, it cannot find the libraries.

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

If it is not a typo, then a \ is missing here
c:Program Files\Java\jre6\bin

should be
c:\Program Files\Java\jre6\bin

and the SIKULI_HOME must be
I:\QA\sikuli\Sikuli-X-1.0rc3\Sikuli-IDE\

(see FAQ 2005)

Revision history for this message
Andrew Munro (andrew-munro) said :
#6

I removed the duplicate sikuli from my path:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Java\jre6\bin;C:\Program Files\MySQL\MySQL Server 5.5\bin;I:\QA\sikuli\Sikuli-X-1.0rc3\Sikuli-IDE\libs

sikuli_home:

I:\QA\sikuli\Sikuli-X-1.0rc3\Sikuli-IDE\

There is nothing to tell it to search for libs in C: so why is it still searching in that directory? Is something specified in org.sikuli.script.SikuliScript to tell it to look there?

I tried running the same setup in my C: drive and it works fine. As soon as I move it to my network drive it breaks.

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

Since this now seems to be a clean setup for the drive (except that it should be SIKULI_HOME, but this should not matter):

What is the error message you get in this situation?

Revision history for this message
Andrew Munro (andrew-munro) said :
#8

"java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: C:\Program Files\Sikuli X\libs\Win32Util.dll: Can't find dependent libraries"

The full stacktrace can be found here: http://pastebin.com/aTKziFEv
but that shouldn't be relevant...

I do not specify anywhere for it to look in C:\Program Files\Sikuli X\libs\Win32Util.dll.

...

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

Just looked into the sources.

Since the environment variable is loaded from within Java using the string "SIKULI_HOME", I guess, the setting must be with uppercase.

I will now check on my Win7 with a stick.

Revision history for this message
Andrew Munro (andrew-munro) said :
#10

Sorry, I gave the wrong information. My variable is all uppercase for SIKULI_HOME, not lowercase (SIKULI_HOME = I:\QA\sikuli\Sikuli-X-1.0rc3\Sikuli-IDE\)

Also, it isn't set to C:\Program Files\Sikuli X\libs\ anywhere in my environment variables so it must be getting it from somewhere else?

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

I tested on my Win 7 (should be no difference on Win XP with these basics) and it works as expected.

for interactive Sikuli session (should be same for a script)
(I had this in a runsik.cmd and ran it from the stick directory)

The original path only contains the jre6/bin-reference.

set SIKULI_HOME=I:\QA\sikuli\Sikuli-X-1.0rc3\Sikuli-IDE\
set PATH=%PATH%;%SIKULI_HOME%libs
@echo ****PATH: %PATH%
java -cp "%SIKULI_HOME%sikuli-script.jar" -i

A problem is, that this path manipulation always adds to the path again, if it is run again in the same command session.
So if you change your batch script and rerun it, the old path is used, which might be the cause for your c: problem.

So for every rerun, you must restart the commandline also, if you do not assure that always the base path is used.

One more problem I had: since I have both Java 6 and Java 7 on my machine, I had to assure, that the java command from JRE6 was used. The only fix I found for that was to use the explicit java.exe location (whatever else I did, java always used Java 7):

"C:\Program Files\Java\jre6\bin\java.exe" -cp "%SIKULI_HOME%sikuli-script.jar" -i

Revision history for this message
Andrew Munro (andrew-munro) said :
#12

Thanks RaiMan, that solved my question.

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

Uuups, what was the solution?

Revision history for this message
Andrew Munro (andrew-munro) said :
#14

Thanks Rai, it's now working across all desired OS's!

A very peculiar issue, I did not realise that it adds the path again causing me all sorts of headaches. As for the jre issue, I find it works fine if I specify the correct java path in my env variables. I will however keep that in mind for the future.

I leave here my final execution code encase it helps someone in the future:

@echo off

set SIKULI_HOME= path_to_sikuli_root_folder
set PATH=%PATH%;%SIKULI_HOME%libs
set JAVA_EXE="java" // set in env variables or use "%PROGRAMFILES%\Java\jre6\bin\java.exe"
if defined PROGRAMFILES(X86) set JAVA_EXE="%PROGRAMFILES(X86)%\Java\jre6\bin\java.exe"

%JAVA_EXE% -Xms64M -Xmx512M -cp "mysql-jdbc.jar;Sikuli-X-1.0rc3\Sikuli-IDE\sikuli-script.jar" org.sikuli.script.SikuliScript SCRIPTNAME.sikuli

This adds external jars to the classpath and executes sikuli using the main class. You can then use your external jars with sikuli (e.g mysql).

Revision history for this message
Andrew Munro (andrew-munro) said :
#15

**Edit** The solution was specifying the SIKULI_HOME from within my .bat file. For some reason it was ignoring my env variables.

I'm not quite sure what the issue was as it worked fine in windows 7 but not in XP. Anyway, working now.