Saturday, February 7, 2015

Hello Jaggery

What is Jaggery ?
Jaggery is a framework to write webapps and HTTP-focused web services for all aspects of the application: front-end, communication, Server-side logic and persistence in pure Javascript. One of the intents of this framework is to reduce the gap between writing web apps and web services. Importantly, Jaggery is open-source and released under Apache 2.0 - JaggeryJS.org

Prerequisites
Java

Getting Started
You can download the jaggery from JaggeryJS.org website. It will download all the things that you need to get your hands dirt with Jaggery.
Extract the downloaded zip folder to anywhere that you like. It will looks like
Jaggery bundles a server with it. You can start the server using the server.sh/bat script in the bin folder.

If the server get started successfully you can access its management console using the
https://localhost:9443/admin/carbon/
Use admin as both username and password.

Hello Jaggery
Now lets see how to write the simplest program that we tend to write when getting start with a new language. That is Hello World.

Open your favorite text editor and have following code on that

 <%  
     print("Hello World!");  
 %>  

Save this file with some name like hello.jag
Note
Remember file extension should be .jag

Deployment
You deploy the created file manually or through the Management console.

Option 1 - Manual
Go to the apps folder in the Jaggery. Create a new directory inside the apps folder with name Hello and copy the file that you created to that.
Option 2 - Using Management Console
Add the created file to a .zip folder and rename zip folder to Hello.zip.
If you are using ubuntu you can easily do this by terminal. Go to the directory where your file exists on the disk from the terminal and type following command.
 zip -r Hello.zip hello.jag  
In windows you can do the same thing by right click on the file and select Compressed zip folder from the Send to menu

After creating the zip folder, login to the management console and select Jaggery from the left hand side navigation pane. Then select the zip file that you created and do the upload.

Note
Remember folder name that you are using will be your application name.

Run the Hello World
Go to the following url from your browser
Here Hello is your application name. This is the name that we gave to the folder which consist of hello.jag file.

You will see Hello World! text get printed on your screen.

No comments:

Post a Comment