[Java] image not found using relative path

Asked by isivay2kx

****** This problem is solved *****

When I execute the below code i am getting following error:

public class SikuliTest {

 public static void main(String[] args) throws Exception {

        Win32Util win=new Win32Util();
        Screen s =new Screen();

         win.switchApp("c:\\Program Files\\Mozilla Firefox\\firefox.exe");
            win.switchApp("Mozilla Firefox");

            s.type("img/Web.png", "www.gmail.com", 0);
        /* s.type("","Key.ENTER",0);
            s.wait(3);
        */
}

}

Windows utilities loaded.
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/awt/AWTUtilities
 at org.sikuli.script.Win32Util.setWindowOpaque(Win32Util.java:79)
 at org.sikuli.script.ScreenHighlighter.init(ScreenHighlighter.java:174)
 at org.sikuli.script.ScreenHighlighter.<init>(ScreenHighlighter.java:287)
 at org.sikuli.script.Screen.initBounds(Screen.java:96)
 at org.sikuli.script.Screen.<init>(Screen.java:108)
 at com.google.test.SikuliTest.main(SikuliTest.java:15)

Running Eclipse
Windows Vista
Env Variables for Java Jre jdk sikuli lib files.

Regards
Siva

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Win32Util needs

path-to-java\jre6\bin in system path.

see FAQ https://answers.launchpad.net/sikuli/+faq/1436

Revision history for this message
isivay2kx (isivay2kx) said :
#2

I already set the path variable for jre in mycomputer-advance settings

Revision history for this message
isivay2kx (isivay2kx) said :
#3

Yes its working fine but i am getting new error for opening the url.
s.type("img/Web.png", "www.gmail.com", 0);

I want to type the www.gmail.com in address bar. From Sikuli i saved the address bar image as Web.png

Exception in thread "main" FindFailed: img\Web.png can't be found.
Line ?, in File ?
 at org.sikuli.script.Region.wait(Region.java:289)
 at org.sikuli.script.Region.find(Region.java:235)
 at org.sikuli.script.Region.getLocationFromPSRML(Region.java:652)
 at org.sikuli.script.Region.click(Region.java:346)
 at org.sikuli.script.Region.type(Region.java:432)
 at com.google.test.SikuliTest.main(SikuliTest.java:19)

Can you please help to resolve the issue.
Need Suggestion click command in java also

Thanks in Advance
Siva

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

--- 1. To get into the address field of Firefox, it is easier to use type("l", KEY_CTRL) than using an image operation and click() (which internally is done when using type(img,text,0))

--- 2. try to use an absolute path to your image. Since I am not developing in Java, I can only guess, that it is related to the bundle path, that Sikuli uses to locate the images. With Sikuli X you have a new option: SIKULI_IMAGE_PATH to tell Sikuli where to look for images (http://sikuli.org/docx/globals.html#index-1)

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

If you want to use Sikuli methods in Java:
see: http://sikuli.org/doc/java-x/

You may access Settings.BundlePath, to point to you images, if it is only one location

Can you help with this problem?

Provide an answer of your own, or ask isivay2kx for more information if necessary.

To post a message you must log in.