[1.0.1] Java: Settings.BundlePath not useable --- use ImageLocator.setBundlePath(path) instead

Asked by akbar

Screen.find("image.png") fails with the latest Java API. The image is definitely present in the bundle path. Throws the following error,

[error] image.png looks like a file, but not on disk. Assume it's text.
[error] Region.find(text): text search is currently switched off
Exception in thread "main" FindFailed: Text search currently switched off
  Line 1671, in file Region.java

 at org.sikuli.script.Region.wait(Region.java:1671)
 at org.sikuli.script.Region.find(Region.java:1590)
 at sample.SampleClass.main(SampleClass.java:31)

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
akbar
Solved:
Last query:
Last reply:
Revision history for this message
akbar (mohammed-akbar-ali) said :
#1

Code,

Settings.BundlePath = "D:\\Sikuli 1.0.1\\";

Screen s = new Screen();

s.find("image.png");

Revision history for this message
akbar (mohammed-akbar-ali) said :
#4

ImageLocator.setBundlePath() worked....

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

I totally revised the ImageLocator feature (addImagePath), since it made many problems in the past.
The so called BundlePath is only defined for usages in Sikuli scripts and has its own setters and getters there.
Using Settings.BundlePath in Java programs was only a convenience-hack, to tell Sikuli in such Java programs, where to find the images (which usually in Java is the current working dir)

So it is no longer internally granted, when you directly change Settings.BundlePath.

You might use ImageLocator.setBundlePath(path) instead, which takes care, that the first entry in the internally managed image path is set to path and hence becomes the so called BundlePath.

Generally spoken: In Java programs one should use the ImageLocator API to handle, where image files should be searched.

In IDEs like NetBeans, Eclipse you can see the ImageLocator API (package org.sikuli.basics) together with the method JavaDocs.