Component Overview
Component Interfaces
Walkthrough Guides

NetBeans Java Library Walkthrough Guide

With the NetBeans walkthrough we are going to be making a very simple Java application demonstrating the usage of the TIBADO Pocket library.

What you need

Step 1 - Create a new Java application project using the IDE of your choice.

To create a new project with NetBeans:

- 'File'-> 'New Project'-> 'Java' Category -> 'Java Application'
- Enter your project name and location and click 'finish'

Step 2- Download the required libraries:

Tibado Pocket Libraries -

JSON in Java Library - JSON In Java

Apache Commons Codec - Apache Commons Codec

Project Dependencies

To add the libraries to a NetBeans project:

Project Properties-> 'Libraries' Category-> 'Compile' Tab-> 'Add JAR/Folder'

To add the libraries to an Eclipse project:

Project Properties-> 'Java Build Path' Category-> 'Libraries' Tab-> 'Add JARs...' or 'Add External JARs...'

Project Files

- /src
- /libs
- /nbproject
- build.xml

Creating an Empty Pocket File

The TIBADO Pocket library can create new pocket files with zero value.

This empty pocket can be merged with a Coin to increase in value:

  File pocketFile = new File("funds.pocket");  Pocket.createEmptyPocketFile(pocketFile);

Example Pocket file:

      "name": "funds.pocket",
      "transactionCount": 0

Initialise Your Pocket

Your local pocket file must first be initialised using the Pocket library:

 Pocket pocket = new Pocket (pocketFile);

Transaction Logs

Your pocket can also have a corresponding transactions log file.

The log files are stored in JSON format.

Simply provide the log file path and the file will be automatically created for you if it does not exist.

 File pocketLogFile   = new File("funds.pocketLog");
 JsonPocketLogger pocketLogger = new JsonPocketLogger(logFile);

Example transaction log file:

 "logEntries": [
     "dateTime": "2016-01-08T09:51:06.604+0000", 
     "type": "DEBIT"
     "dateTime": "2016-01-08T09:51:56.598+0000", 
     "type": "DEBIT"
     "dateTime": "2016-01-08T10:02:07.801+0000",
     "type": "DEBIT"
 "name": "funds.pocketLog",
 "transactionCount": 5

Transaction Count

Both the pocket file and pocket log file have a transaction count.

This counter is essentially the Pockets file revision number, which is incremented for both files following a transaction.

The transaction count can be used for backing up and syncing Pocket files.

TIBADO Pocket Operations

To increase a pockets value, a coin can be stored within the pocket.

To take value out of the pocket, you can get coins out of the pocket.

- The pocket API can get a coin from a pocket.

 Int amountInCents = 1;
 Coin coin = pocket.getCoin(amountInCents);
 String valueText = coin.getBase64Context();

- The pocket API can store a coin into a pocket.

 Coin coin = new TextCoin(valueText);
 pocket.storeCoin (coin);

Running the Sample

Use your IDE to add necessary Java imports.

Finally handle the exceptions by surrounding with try-catch or add a throws signature to main.

Your sample is now complete.


Contact Us

If you require further information regarding TIBADO please get in touch and we will get right back to you.

Our Address

Gratwicke House,
10 East Street, Littlehampton
West Sussex, BN17 6AW

t: +44 (0)1903 723 548
e: This email address is being protected from spambots. You need JavaScript enabled to view it.


Connect With Us