1

I am currently using Sikuli which requies both a PATH and SIKULI_PATH environment variable to be set in order to execute. Applying this in the run config is fairly straight forward and allows me to run the script as intended from within Eclipse.

Exporting the runnable JAR is working well with everything except UnsatisfiedLinkError is being thrown which was the same exception I would receive when I didn't have the aforementioned variables set.

Is there a convenient way to export the below settings into the runnable JAR?: enter image description here

The idea is to essentially generate a stand-alone executable JAR that executes the Sikuli script.

I have attempted to manually set PATHand SIKULI_HOME which worked as intended (echo %PATH% & echo %SIKULI_HOME% both print the required paths). However I'm still receiving the same UnsatisfiedLinkError. Below is the relevant StackTrace:

C:\Users\XXXXX\Desktop>java -jar sikuli.jar -Dsikuli.Debug=3 -Djava.library.path = "C:\Program Files (x86)\Sikuli X\"
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at     org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.UnsatisfiedLinkError: C:\Program Files (x86)\Sikuli X\libs\Win32Util.dll: Can't find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.wapmx.nativeutils.jniloader.NativeLoader.loadLibrary(NativeLoader.java:44)
    at org.sikuli.script.Win32Util.<clinit>(Win32Util.java:19)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.sikuli.script.Env.getOSUtil(Env.java:91)
    at org.sikuli.script.ScreenHighlighter.init(ScreenHighlighter.java:180)
    at org.sikuli.script.ScreenHighlighter.<init>(ScreenHighlighter.java:293)
    at org.sikuli.script.Screen.initBounds(Screen.java:105)
    at org.sikuli.script.Screen.<init>(Screen.java:117)
    at org.sikuli.tests.TestSikuli.main(TestSikuli.java:13)
Juxhin
  • 5,068
  • 8
  • 29
  • 55

2 Answers2

2

I don't think there is an out of the box way, since this is os specific. If you're on Windows, just create a batch file with lines along

 set PATH=%PATH%;...
 set SIKULI_HOME=...
 %JAVA_HOME%\bin\java yourrunnable.jar
JP Moresmau
  • 7,388
  • 17
  • 31
  • I was thinking of doing that however that will overwrite the `PATH` variables I currently have set on my machine. Setting `PATH` to `C:\Program Files (x86)\Sikuli X\libs` with then not allow me to actually run `java -jar` unless I'm missing something blatantly obvious. – Juxhin Jul 10 '15 at 15:19
  • You can add things to the current PATH without losing the existing value, I've edited my answer. – JP Moresmau Jul 10 '15 at 15:22
  • Yep just scouted around and saw that. Much better that way. I'll test it out first and let you know. – Juxhin Jul 10 '15 at 15:23
  • So, a quick update. I've set the environment paths smoothly so that was fine. However the same `UnsatisfiedLinkError` exception is being thrown as it is unable to get the `C:\Program Files (x86)\Sikuli X\libs\Win32Util.dll` which should be found in `PATH` – Juxhin Jul 10 '15 at 15:27
  • should be or is found in the directory specified in the PATH variable? I suspect its just missing – Mark W Jul 10 '15 at 17:32
0

Adding an environment variable was not sufficient. I had to log in as Administrator and set up System Variables and append the Sikuli libs path in PATH and create a SIKULI_HOME path with the base path for SikuliX.

After that I read that it is not recommended to maintain the Sikuli files within Program Files(x86) and instead moved them over to C:\Users\my_user\SikuliX.


Also, the Sikuli-Java.jar is not to be kept within the project workspace (and referenced internally) but rather outside of the project (actually SikuliX path) and should always be kept there.

If you modify any folders regarding SikuliX be sure to remove redundant copies to avoid possible collision issues with future updates.

Some of this information may be redundant such as the movement from Program Files to User folder however that solved the issue for me.


Note—if any modifications are made to System Variables, be sure to atleast logout and log back in so that they take affect.

Juxhin
  • 5,068
  • 8
  • 29
  • 55