Creating windows executable launcher of our Java web application

In this tutorial we will see how to create exe launcher for Java web application. For simplicity let us divide this tutorial in several parts. In the first part we will create simple jar launcher which can deploy our web application in embedded server. After successfully achieving this we will see how can we create exe file from it using Java Native interface (JNI).

1. Create launcher jar file using embedded Glassfish api which will remove dependency of server on machine
2. Create exe using JNI invocation API
Part 1:
Lets start with embedding webserver/servlet container in our Java program. Glassfish and Tomcat both provide an api for embedding server in java application. We will be using Glassfish for achieving our purpose.
Here is a test program for launching simple web application:
package test.glassfish;
import org.glassfish.api.deployment.DeployCommandParameters;
import org.glassfish.api.embedded.*;

public class WebApplication {
public static void main(String[] args) throws IOException, LifecycleException {
Server.Builder builder = new Server.Builder(“test”);
Server server =;
ContainerBuilder containerBuilder = server.createConfig(ContainerBuilder.Type.web);
File war = new File(“C:\\Users\\sunils\\maventests\\simple-webapp\\target\\simple-webapp.war“);
EmbeddedDeployer deployer = server.getDeployer();
DeployCommandParameters params = new DeployCommandParameters();
params.contextroot = “simple”;
deployer.deploy(war, params);
You just need to change path to war file. You should have your web application started under domain http://localhost:8080/simple

As this is embedded server and we want to create exe out of it we need a way to get logging out of it. In next part we will see how to exe launcher from above program

Checked vs Unchecked exception

Checked Exception Unchecked Exception
Forces clients to handle it Clients may not handle it
All exceptions except RuntimeException , Error and their subclasses come under checked exception All RuntimeException , Error and their subclasses come under unchecked exception

Difference between C++ references and Java references

Many people who learn Java with a background of C++ often get confused between reference of C++ and reference of Java. Even if they share same phrase there is not much similarity between them. You might wonder that C++ pointers share the similar functionality that of Java references.

Here is the similarity between C++ pointers and Java references.

C++ Pointers Java references
Declaration and assignment:
Obj* o1;//Uptil now no memory is allocated on heap
o1=new Obj();//Now we have o1 pointing to object on heap
Declaration and assignment:Obj o1;//Uptil now no memory is allocated
o1=new Obj();//Now we have o1 pointing to object on heap
Base class pointer can point to derived class object Base claas reference pointes to derived class object
Obj* o1,o2; o1=new Obj();
o1 and o2 now point to same object
Obj o1,o2; o1=new Obj();
o1 and o2 now point to same object

In C++ if we try to assign derived class object to base class reference, object slicing will occur.
From this you can get a idea about how much strong the references are, they allow runtime polymorphism without dealing with pointers. In case of pointers you need to free the memory allocated for pointers. In Java we do not need to wory about freeing allocated memory because system(JVM) takes care of it. So Java tried to achive best of both the worlds. This all comes at the price. As garbage collection ( name of background thread responsible for releasing allocated memory ) run as a background process it slows down the system.

Creating your first website

Just follow following steps and get full fledged website running for you

  • Get an account with web host (you can use
  • Domain name(optional if webhost provides it or you can get friendly name at )
  • Website written in PHP (Or you can use CMS i.e. Content management system) Many CMS’s provided by 110mb. you have to just click on ‘one click application installer’ and select appropriate CMS (Before installing CMS delete index.html file through file manager through 110mb controle panel)
  • If you want to have email addresses with your domain you can open google apps account at
  • If your website/CMS requires a database you can get free database here (It may take one or two days to activate)
After completing all the above steps I assume:
  • You have an account with web host provider
  • You have domain name with
  • If you are using CMS ,CMS files uploaded to your root of website.
  • If your website/CMS requires database you have database account with you.
  • If you want friendly domain name you have domain name. And if you want emails with your websites you have google apps account.

Now let us start setting things up.
  • Log into your google apps account you will get instructions to select verification method, select ‘Change CNAME recordoption, press continue
  • Copy the unique string provided to you.
  • Open another tab and navigate to website, login to your account, select manage your domain name, press set up. Click on “url forwarding” , Select check box “Google apps email setup”, Paste this string to text box. Enter the title. press “Set Up”.
  • Switch back to your google apps tab press “I have completed steps above”
  • You will be prompted to follow guid, Go through the guid if you want to. It will open in different tab. When you complete exploring switch back to prev google apps tab.
  • Press activate email under Email link
  • You will get list of instructions for changing mail extensions. Don’t worry no need to follow those as has already done that for us. just press “I have completed these steps”
You have just set up an email account for your custom domain. It will take around one or two days to activate depending on your location.
Now let us come back to your website at
You will have a domain name with your website like [xxxxxx] Now you have to configure your domain name with 110mb.
  • Log into your 110mb account
  • Click on- Account management and Upgrade section – Account profile
  • Under Add new domain enter your domain name [ DO NOT PREFIX WITH www] i.e. do not enter just enter
  • Press “Add or remove My domain now”
  • Go to enter your 110mb domain i.e.
  • Copy the ip address.
  • Go to your domain manager settings as explained previously. Press set up.
  • Press zonal records, there you will have all the configuration for your domain
  • Delete the record having

    <yourname> 1 H A

  • Under add arecord click on textbox next to host.(Do not enter anything)
  • Select Type as “A”
  • Paste the ip address you had copied from 110mb domain doctor website
  • Press Set up
Thats it. you have now configured your domain name to point to 110mb domain. This may take two days two take efect.
Now considering that your database is active.
Navigate to your address
You will be prompted to enter information depending on your CMS. Enter database username, password, database name given to you by Enter Server name as
And just follow the steps.

I hope this information was useful

CODD’s Rules

Edgar F. Codd is a father of RDBMS ( Relational database management system )

He has putforth twelve rules which DBMS must follow ( 10 followed by Oracle 2 partialy followed )
These rules are
  • Information rule
  • Gauranted access
  • Systematic treatement to NULL
  • Active online catalog
  • Comprehensive data language
  • View updating rule
  • High level Insert,Update,Delete
  • Physical data independence
  • Logical data indepence
  • Distributed independence
  • Integrity indepence
  • No subversion rule

Information rule: It states that all information shold be stored in tables. Information about the tables should also be stored in tables.

Guaranted Access: It states that if you know table name and primary key you should be able to recover unique record.
Systematic treatement to NULL: It states that NULL is not confined to any datatype but it can be stored in all datatypes.
Active Online Catalog: It states that all information about databases should be stored in data dictionary which should be maintained by DBMS.
Comprehensive data language: This rule states that all data should be accessible by language. All DBMS follows this by providing SQL.
View updating rule: All views should be able to do DML operations. (Not followed by all DMBS not even Oracle).
High level Insert,Update,Delete: High level insert update delete should be possible i.e. it should affect multiple records with single query
Physical data independence: This rule states that where data is stored should be taken care by Operating System. This rule is partially followed by Oracle. Oracle tells OS where to store data using hash.
Logical data indepence: This rule states that data can be present anywhere physically but it should be accessible using same query. e.g. when we run select query we get desired result every time even when DBMS keeps on modifying location where data is stored for efficiency purposes.
Integrity independence:
  1. Entety integrity – Concept of primary key
  2. Referncial integrity – Concept of foreign key
  3. Domail integrity – Concept of data type
Distributed independence: DBMS should support distributed database. Followed by oracle.
Non-subversion rule: If relational system has low level language this language should not bypass integrity constraints

Welcome to this blog

I have stated this blog to share whatever i learned building website

I have made an attempt to build fully ajax website using

  • RSH0.6 you can read more here
  • XML you can read more here
  • PHP you can read more here
  • MYSQL you can read more here
  • FCK EDITOR you can read more here

If you try navigating this website you will find that for each request entire page will not be loaded instead only dynamic part is loaded, this is achived with the help of xml responce

My Xml Responce contains n nodes

Its DTD is as follows

<!ELEMENT node (eval
(location,( data error ))) >

<!ELEMENT location


Each node is responsible one of three things

  • Changing innerHTML of one of the elements
  • Raises error using javascript alert
  • Evaluating javascript statements

Example of first type is

some formated data


This node will be responsible for changing innerHTML of element having id id_of_some_element_in_html.

Example of second type is


error occured on server



This node will be responsible for producing alert statement using javascript

And finally example of third type is

javascript statement

This node is responsible for evaluating statement on client side

After receiving this responce via ajax you can hand it over to javascript function which will do the parsing

The javascript function i have written is

the one that i have written is

function parseXMLResponce(text){




Chopping the advertisement code emited by some free hosts



/*Obtaining DomDocument depending on browser*/

var xmlDoc;

var browser=navigator.appName;

if(browser!=’Netscape’) {





} else {

try //Firefox, Mozilla,












var nodeArray;



//Taking all nodes
in array





logging javascript error on server using ajax

this will let us know how website is performing

you can
also send browser information in function “logJavascriptError”

contains responce received e.message is general way to get error



alert(‘parse error, please try again’);



//collecting the first node

var node=nodeArray[0];





var info=node.childNodes;

var info_no=info.length;

var location=””;

var data=””;

var error=””;


var statement=”;





if(info[j].nodeName==”data”) {



if(info[j].nodeName==”error” &&

info[j].hasChildNodes()==true) {



if(info[j].nodeName==”eval” &&

info[j].hasChildNodes()==true) {






//printing the node value in






else if(error!=”)


//alerting and displaying error in







else if(statement!=””)


javascript statement











//moving on to next sibling