[1.1.1] Jython interactive shell

Asked by Jesse Sanford

***** the options ---------------
--1: use the bundled Jython in sikulix.jar
runsikulix(.cmd) -i on a commandline
(see: http://sikulix-2014.readthedocs.io/en/latest/faq/010-command-line.html#command-line-options-special)

--2: use an external Jython
according to the steps in
https://github.com/RaiMan/SikuliX-2014/wiki/Usage-in-Java-programming
(only take care for sikulixapi.jar on classpath)

or like mentioned here in comment #1
(take care for classpath and Jython sys.path)
-----------------------------

There is plenty of old documentation and questions/answers on how to do this with the sikuli-script.jar but not with the current sikulix project jars. I am hoping that we can get a working example of how to launch a jython interactive interpreter with the correct classpath set (including correct sikulix jars and libs folders) as well as showing how to import sikulix modules and classes into the python shell and to execute a sikuli x command from the shell "popup('hallo')" from this example would work: https://answers.launchpad.net/sikuli/+question/230599

I think that this will help people who are scouring google links for up to date information immensely.

Cheers,
Jesse

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Jesse Sanford
Solved:
Last query:
Last reply:
Revision history for this message
Jesse Sanford (jessesanford) said :
#1

I am going to answer my own question to save raiman some time. Using the answer from: https://answers.launchpad.net/sikuli/+question/261208 I was able to piece this together:

1) Install sikulix >= 1.1.0 using the setup.jar that comes with it. (Install to an easy location like c:\sikulix)
2) Install java and jython. (Install to an easy location like c:\jython2.7)

3) Create the following environment in a command shell or batch script and run:

set JYTHON_HOME=c:\jython2.7.0\
set SIKULIX_HOME=c:\sikulix\
set JYTHONPATH=%SIKULIX_HOME%sikulixapi.jar\Lib
set CLASSPATH=%SIKULIX_HOME%sikulixapi.jar;%CLASSPATH%
java -cp %JYTHON_HOME%jython.jar;%CLASSPATH% org.python.util.jython

4) You will end up with an interactive python repl:
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
[Java HotSpot(TM) Client VM (Oracle Corporation)] on java1.8.0_91
Type "help", "copyright", "credits" or "license" for more information.
>>>

5) import popup from sikuli
>>> from sikuli import popup

6) call popup('hallo')
>>> popup('hallo')