SilkuliX can't find images in an executable jar.

Asked by Spencer Keller

I'm packaging a SikuliX application up as an executable jar file and I'm having trouble with the path to the images. The jar file has a directory called /images where all of the .png files live but when I pass “images/icon.png” to any method that takes a PFRML the image can not be found. SikuliX is looking in the current working directory so I get a message like:

[error] Image: could not be loaded: file:/C:/sandbox/qe/target/file:/B:/sandbox/qe/target/qe-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/images/icon.png

How do I get SikuliX to look in the “images” directory of the jar file?

Thanks,
Spence

Question information

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

Thank you.

spence

On Wed, Dec 30, 2015 at 1:09 AM, RaiMan <
<email address hidden>> wrote:

> Your question #280218 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/280218
>
> Status: Open => Answered
>
> RaiMan proposed the following answer:
> supposing 1.1.0 see:
>
> http://sikulix-2014.readthedocs.org/en/latest/scripting.html#image-search-path-where-sikulix-looks-for-image-files
>
> towards end of paragraph (Java usage)
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/sikuli/+question/280218/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/sikuli/+question/280218
>
> You received this question notification because you asked the question.
>

--
*Spencer Keller*
*Software Engineer, SolidFire, Inc.*
e: <email address hidden> <email address hidden>
d:+1 303.591.1448

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

seems to be solved

Revision history for this message
Spencer Keller (spencer-keller) said :
#4

Hello,
I would like to re-open this question. I still can not get this to work. Back in December I was working on a POC (Proof of Concept) and never actually got this working. Now I MUST get it working and I must be doing something wrong. I've read post #235137, read bug #1220640 and the documentation at http://sikulix-2014.readthedocs.org/en/latest/faq/030-java-dev.html and I still can not get this working. I am developing with Eclipse, Maven, Sikuli 1.1.0, and my images file are in “{projectroot}/src/main/resources/images”. I have tried the example in the documentation link above and when I make the call to “ImagePath.add(“MyClass/images”);” I get error:

[error] ImagePath: add: MyClass not found on classpath.
Followed by:
[error] ImagePath: add: not valid: MyClass/images

In addition to passing “MyClass/images” have also tried passing “MyClass.class/images” and “com.foo.dat.MyClass.class/images” with the same result.

What am I doing wrong?

Also another related question. I'm building a rather large automated testing system and have a number of image files with the same name just in different directory locations. How would I call Region wait/click, etc?

Thanks,
Spence

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

ok, just tested.

this is an example that should work in Eclipse:
https://dl.dropboxusercontent.com/u/42895525/MavenTest.zip

Revision history for this message
Spencer Keller (spencer-keller) said :
#6

I am all set. I am embarrased to say that I had "fat fingered" my classname. It is working perfectly and I can specify the full path to my images so they are unique. ex: "project/createuser/ok-button.png" and "project/deleteuser/ok-button.png" It works great. Sorry to have bothered you with this.

Thanks,
Spence

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

no problem.

Revision history for this message
Henrique (guima) said :
#8

I also need help with this. Looks like the links are not working anymore, can anyone provide another solution?

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

@Henrique
Please post your own question with details about your environment and the problem you have.
sample code is helpful.

Be aware: preferably version 1.1.4.