← Back to team overview

sikuli-driver team mailing list archive

[Question #285168]: Simple java program using Sikuli API does not terminate java process when returns from main

 

New question #285168 on Sikuli:
https://answers.launchpad.net/sikuli/+question/285168

Hi! I'm new to Sikuli, but I'm trying to use it for some UI automation on Ubuntu 15.10 amd64 system. At first I created a python script that launches firefox, sleeps for a few seconds, closes firefox and then exits. It looks something like this:

openApp("firefox")
sleep(5)
switchApp("firefox")
closeApp("firefox")

And I run it with runsikulix -c -d 3 -r test.sikuli
It runs as expected.

Running this script using jython is somewhat slow, ie, the startup before firefox launches is 5-7 seconds, so I decided to port it to using native Java, but I'm seeing an issue where at the end of main, the java process does not terminate. Even something as simple as this fails to exit back to command line:

import org.sikuli.script.*;

public class test
{
    public static void main(String[] args)
    {
        System.out.println("Hello");
        Screen s = new Screen();
        System.out.println("Bye");
    }
}

It prints Hello and Bye to console, but then it just sits there. I'm using this to compile/run it:
javac -classpath ./sikulix/sikulixapi.jar:. test.java
java -classpath ./sikulix/sikulixapi.jar:. test

Commenting out Screen s = new Screen(); line allows the java program to terminate. My setup is as follows:

- Ubuntu 15.10 amd64
- Sikulix 1.1.0
Java info:
$ java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.15.10.1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
$ javac -version
javac 1.7.0_95

This is how I setup Sikulix
wget https://launchpad.net/sikuli/sikulix/1.1.0/+download/sikulixsetup-1.1.0.jar
java -jar sikulixsetup-1.1.0.jar options 1.1 2

Not sure how to proceed... I'd really like to use native java to automate the tasks I need, but can't get past the fact that using Sikuli from Java prevents java program from terminating... Do I need to call some Sikulix Java API to exit?

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