← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #707833]: Having problems accessing images from a runnable jar, using Sikuli 2.0.5

 

Question #707833 on SikuliX changed:
https://answers.launchpad.net/sikuli/+question/707833

Description changed to:
I have a maven project that builds a runnable jar file and I am trying
to make Sikuli recognize and access the image path.  I am using eclipse
IDE and the images are accessed as expected when running in the IDE.  As
soon as i copy/move the .jar file to a different location than the
target/ directory, I receive not-found exceptions on the images.  The
.jar file contains and images/ folder on the root level with the images
in it.

In general this is the code:
Debug.on(3)
ImagePath.add("src/main/resources/images"); 
try {
	Screen.all().find("desktop-postman.png");
	System.out.println("All good, found image...");
} catch (FindFailed e) {
	System.out.println("Hmmm, did not find the image, " + e.getMessage());
}


The output from the run:
X:\CeesoftDev>java -cp CeeviewSikuli.jar com.carstein.test.sikuli.TestImage
[ERROR Commons] parameter(main: src/main/resources/images, sub: null)
[ERROR Commons] makeURL: file does not exist: X:\CeesoftDev\src\main\resources\images
[debug] Screen: initScreens: starting
[debug] Screen: Accessing: GraphicsEnvironment.getLocalGraphicsEnvironment()
[debug] Screen: Accessing: GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()
[debug] Screen: Monitor 0: (1920, 0) 1920 x 1080
[debug] Screen: ScreenDevice 1 has (0,0) --- will be primary Screen(0)
[debug] Screen: Monitor 1: (0, 0) 1920 x 1080
[debug] Screen: initScreens: monitor mouse check
[debug] Screen: *** checking: R[0,0 1920x1080]@S(0) center: (960, 540) --- OK
[debug] Screen: *** checking: R[1920,0 1920x1080]@S(1) center: (2880, 540) --- OK
[debug] Screen: initScreens: ending
[error] ImagePath: find: not there: desktop-postman.png
[debug] ImagePath: ImagePath has 1 entries (valid 0)
[debug] ImagePath: BundlePath: --- not set ---
[debug] Region: find: waiting 0 secs for desktop-postman.png to appear in R[0,0 3840x1080]@S(Union)
[debug] Region: find: desktop-postman.png did not appear [0 msec]
[debug] Region: handleFindFailed: desktop-postman.png
FindFailed: desktop-postman.png: (0x0) in R[0,0 3840x1080]@S(Union)
  Line 2291, in file Region.java

        at org.sikuli.script.Region.find(Region.java:2291)
        at com.carstein.test.sikuli.TestImage.main(TestImage.java:17)
What am I doing wrong ?

It works when running in IDE, and from the project directory in a shell
using: java -jar target/myjar.jar but now when "outside" the expected
folder structure.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for SikuliX.