← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #165384]: JRuby: Java NullPointerException if imagefile not found

 

Question #165384 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/165384

RaiMan proposed the following answer:
--- nothing special with the Java example

import org.sikuli.script.*;
public class test {
	public static void main(String[] args) throws FindFailed{
		Screen s = new Screen();
		s.click("images/img.png", 0); # this image does not exist
		s.getLastMatch().highlight(2);
	}
}

--- the JRuby approach

I have a separate JRuby module to define some constants and global
variables and to add/alias/overwrite some features of JRuby and Sikuli.

e.g.

Sikuli = Java::org.sikuli.script
so I can say later on Sikuli::Region.new

I use symbols to name may images and have added to_img to Object::Symbol
to return a valid filename for just :img1.to_img (gets
"prefix_img1.png")

some more things in Region (wait for multiple images, type for my german
keyboard and using symbols for the keys, ...) and App class.

And I stick to the official public top level API (so I use find and not
doFind).

So I think, nothing else can be done, to avoid this error.

I will check it now a little bit deeper (though I am also busy with OS X
Lion ;-)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.