Jython Walkthrough Guide
The Jython walkthrough is intended to provide the reader with a easy hands-on experience of using the TIBADO Pocket library.
Jython is an implementation of the Python programming language and is designed to run on the JAVA platform which allows us to utilise the TIBADO Java Pocket library from within Jython's interactive console.
What you need
Download and installation requirements
Tibado Pocket Libraries - tibado_libs.zip
Jython - http://www.jython.org/downloads.html
JSON in Java Library - JSON In Java
Apache Commons Codec - Apache Commons Codec
Jython must be launched from the command prompt and when launched Jython must be made aware of the location of the TIBADO Pocket Library and dependent libraries listed above.
For convenience, it is recommened that you create a directory and place the three jar libraries within it.
c:\tibado >dir Volume in drive C has no label. Volume Serial Number is 163D-D315
Directory of c:\tibado 14/01/2016 15:04 DIR . 14/01/2016 15:04 DIR .. 17/12/2015 14:39 284,184 commons-codec-1.10.jar 17/12/2015 14:38 40,375 org.json-20120521.jar 14/01/2016 09:22 37,400 tibado2-api-java.jar 3 File(s) 361,959 bytes 2 Dir(s) 1,870,218,940,416 bytes free
Now the dependent libraries are all within your current directory, the command to launch Jython would be as follows:
c:\tibado> C:\jython2.7.0\bin\Jython -J-classpath tibado2-api-java.jar;org.json-20120521.jar;commons-codec-1.10.jar;
and the Jython interactive console appears.
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11) [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_66 Type "help", "copyright", "credits" or "license" for more information. >>>
New Pocket Creation
To create a new pocket, you must first decide on a name and location for a file to be created which represents your pocket.
>>> from java.io import File >>> pf = File("HolidayFunds.pocket") >>> from com.tibado import Pocket >>> Pocket.createEmptyPocketFile(pf)
Once a pocket file has been created you may now instantiate it as a Pocket object.
>>> p = Pocket(pf)
and run its methods:
>>> p.getBalance() 0 >>> p.getCoin(1) Insufficient Funds