Convert my Sikuli python script in a java (obfuscated) standalone package --- available in 1.1.2 after 2017-11-29

Asked by Max on 2017-11-11

------------------------- solution information

see faq 2947


Preface: I'm not a software developer and have never developed anything in java :)
I developed some sikuli scripts in python to automate actions for my researches (I work in academia).

Now I need to build a java standalone package for one of my programs (with the obfuscation) to be able to run it without installing and configure sikuli when I move or if I need to lend it to other departments.

I asked already the question here =>
 but could not performed already the second step...

I have my script in a folder "my_program.sikuli":


So far I just compiled my py script with jython obtaining a .class file

$JYTHON_HOME/jython $JYTHON_HOME/Lib/ /home/my_program.sikuli/

===> a new file called "script$py.class" is in /home/my_program.sikuli/

Now I have no idea what to do and how to do it! In the link they spoke about wrappers and but cannot understand what to do.

Could you help me explaining step by step the actions?

Thank you very much for your support!!!!!!!

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

Currently I am on holiday for 2 weeks. When I am back, I will have a look at it. Thanks for finding the interesting post.

Max (max883) said : #2


Max (max883) said : #3

any idea?!? :)

RaiMan (raimund-hocke) said : #4

some patience ? ;-) see comment #1

Max (max883) said : #5

eheheh yep sorry :P my apologies!

RaiMan (raimund-hocke) said : #6

ok, it is a bit of a challenge ;-)

... but I have decided to make it !!!

I guess later tomorrow there will be a compact solution, that allows, to create a jar, that runs a compiled (hence obfuscated) script with just saying:
java -jar myscript.jar

everything needed to run the script is contained in the jar.

--- planned extras:
- stuff needed to be imported can be integrated (including other jar files)
- images will be integrated and loaded from the jar at runtime

To create the script jar, you will have to say something like this:
java -jar sikulixsetup... scriptjar folder-containing-script optional:folder-containing-images optional:other-stuff

Hope you can wait ;-)

Max (max883) said : #7

of course!!! this sounds amazing!!!!!!!!!!!!!!!!!!!!!!!!!!!

Best RaiMan (raimund-hocke) said : #8

Here you are with a basic solution:

- run a setup with the latest nightly 1.1.2 (select option 1 and 2)

- in the setup folder run
java -jar sikulixsetup-1.1.2-....jar scriptjar <path-to-your-script>

- if everything works, you get a script.jar (which you might rename as you like)

- to run your script jar:
java -jar <path-to-script-jar>

Be aware:
- with every script, that you pack this way, you get a jar that at least has 60MB
- this only works for one script currently

For now I decided to leave it experimental for now and undocumented, because it does not look like the ultimate solution ;-)

My idea is to have a runner jar, that can be used to run other jars, that only contain obfuscated/compiled scripts.

The overall challenge is to allow imports and assure access to image files contained in the scripts.

Max (max883) said : #9

Excellent!!! I will try tonight :) Thank you sooooo much for your help!!!!!!!!!! I'll let you know the result ;)
Thanks again!

Test App (laxmisaketha) said : #10

Hi Raiman,

With reference to question, you have suggested me to try the above solution

I installed Sikuli 1.2 and was able to generate a script.jar file
After this i created a run.bat file to run my script.jar

java -jar <path-to-script-jar>

Running the run.bat file does not execute my script

However when i click on script.jar i am able to run my script , I could probably live with this , But to perform certain actions on windows, i have to run as administrator , So right clicking on run.bat file and running as administrator would execute my scripts But in this case i somehow cannot run the bat file

Request your expertise on this


Test App (laxmisaketha) said : #11

I am sorry Raiman

Had a typo in my batch file was supposed to be java -jar (with a space)
Thank you so much , the solution worked :)

Max (max883) said : #12

It works! Thanks again, amazing solution :)

Max (max883) said : #13

Thanks RaiMan, that solved my question.

RaiMan (raimund-hocke) said : #14

Fine, thanks for feedback.

I decided, to add the jar-packing for scripts into the IDE file menu as "Export to jar" (script only) and "Export to run jar" (self running including sikulixapi and Jython).

Also I will add the jar variant to the different script run options (only relevant for the script-only version).

In version 2 this will be the only option to save and run any scripts (while .sikuli and .skl can still be loaded).

RaiMan (raimund-hocke) said : #15

Be aware:
the current solution (the one you are using) creates a jar, that only works on the same system type:
- created on Windows only runs on Windows
- created on Mac .....

The final solution will have an option to select the target system (which then will have the correct native library package).

RaiMan (raimund-hocke) said : #16

I made some slight changes.

So with a SikuliX 1.1.2 after Nov 29th you have to read faq 2947 carefully ;-)