creating standalone jar of sikuli jython scripts and related images --- solved see faq 2947

Asked by Akhil Ahuja on 2018-02-23

---------------- was already solved November 2017:
https://answers.launchpad.net/sikuli/+question/660613

together with faq 2947
--------------------------------------------------

I went through this tutorial for creating jar to run sikuli scripts on systems without sikuli installed: https://sikulix-2014.readthedocs.io/en/latest/scenarios.html#prepare-and-use-your-own-jar-files-in-the-jython-environment

I couldn't make it work. I'm using sikuli version 1.1.1. I have a .py file in which there are two lines:
from sikuli import *
click(imagePath)

how can i package this in a standalone jar which could be run with java on other systems without sikuli installation? and also compileJythonFolder(source, target) is returning False?

Thank you so much!

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2018-03-06
Last query:
2018-03-06
Last reply:
2018-03-05
RaiMan (raimund-hocke) said : #1

Sorry, but the above mentioned recipe still needs Java and SikuliX on the target system.

If you want a package, that does not need SikuliX on the target system it gets a bit more complex:
- you have to use a packaging tool like Ant, Maven, Gradle, ...
- or do the production in an IDE like Eclipse or IntelliJ IDEA
- you need a Java main program, that is executed, when the jar is run with java -jar mypackage.jar, and does what you want

The easiest would be, when you decide, to implement your workflows directly with Java code.

What is the intention for your plan?

Akhil Ahuja (akhilahuja927) said : #2

Develop scripts for automation using sikuli. Then distribute single jar file which can be run with java by simple double clicking the jar file. Because sikuli installation is not possible for everyone to do. Basically creating an application type experience for sikuli scripts.

Though I found one stackoverflow answer which promises to do above mentioned things but i couldn't properly follow it.
https://stackoverflow.com/questions/47042941/jar-or-exe-file-from-sikuli-python-script

RaiMan (raimund-hocke) said : #3

ok, understood.

thanks for the pointer to stackoverflow.
The first answer indeed shows the stony way to get what you want.
... and is for version 1.0.1, which is no longer supported.

I will edit the answer to reflect latest SikuliX. May take a while.

Since currently there is no compound SikuliX feature, I will have a look into it during the next days.

In the end it should be an additional option for setup (run from command line with parameters).

Please be patient for some days - I will keep you informed here.

The solution will be available in version 1.1.2 nightly.

Akhil Ahuja (akhilahuja927) said : #4

fingers crossed! I also believe that this will turn out to be a useful feature. Because if you can distribute your work for others to use, it will always grow. Waiting very excitedly.

Akhil Ahuja (akhilahuja927) said : #5

https://answers.launchpad.net/sikuli/+question/660613

https://answers.launchpad.net/sikuli/+faq/2947

Hi Raiman,
Are above mentioned links deals with similar problem I'm facing?
Because I setup sikuli 1.1.2. I created fat-jar as you would say. But when I run that jar using java -jar myapp.jar, it says click is not defined.

Can you help me with this one?

Thanks

Akhil Ahuja (akhilahuja927) said : #6

I am able to produce standalone jar now. Thank you raiman. This works for scripts created using Sikuli IDE. There I can easily export the script as runnable jar with sikuli 1.1.2 .

But I am not able to get it work for scripts written in jython. This step java -jar sikulixsetup-1.1.2-....jar scriptjar <path-to-your-script> tries to install again sikuli 1.1.2 rather than creating fat-jar. What am i missing here?

what is sikulixsetup-1.1.2-....jar file? I think I might be confused here a little bit.
scriptjar is jar to be created.
path to script is path to scripts first and then path to images.

Thank you raiman for your help.

Best RaiMan (raimund-hocke) said : #7

LOL, did not remember, that the feature already exists. Thanks for the pointer.

To work correctly, you need a valid xxx.sikuli folder.

The trick with a plain Jython script myscript.py:
just put it in a folder named myscript.sikuli and run
java -jar sikulixsetup....jar scriptjar path-to-myscript.sikuli

sikulixsetup....jar is the jar file, you used for setting up SikuliX.

Akhil Ahuja (akhilahuja927) said : #9

Thanks RaiMan, that solved my question.