Developing Database Applications with WebAppRunner

WebAppRunner is the Eclipse RCP application I created to run web applications as standalone desktop applications. I had explained earlier how this application could be used by creating a demo FileList application. In this post I am going to show how WebAppRunner can be used to create Database applications.

I have created a demo application, SQLiteApp.

This is a simple application that allows CRUD operations on a simple Employee table. User interface for this application is created using HTML/JS. The database APIs are implemented in empDBManager.jar included in To see how this application works, execute it by passing path of this Zip file to WebAppRunner. ‘Open DB’ allows you to open existing SQLite (employee) database. Click ‘Create DB’ to create a new employee database. Click ‘Add’ button to add a new employee record.

I have made a few changes to WebAppRunner.

  • I have added three new APIs in WebAppRunner.
    • setJavaProperty : To set value of a public field of Java object
    • getApplicationPath : To get path of the application that is opened in the WebAppRunner
    • exitWebAppRunner : To exit WebAppRunner
  • Objects created/retrieved with Java APIs for WebAppRunner can now be passed as arguments by prefixing $ to the variable name.
  • You can specify if menu bar of WebAppRunner be displayed by specifying Show-Menubar: false/true in the application’s

I have updated WebAppRunner post with detailed description of above changes. I have also uploaded the new version (1.1 Beta) of WebAppRunner with these changes at the same locations –

Packaging of Java APIs for SQLiteApp

As mentioned earlier, Java classes to create SQLite DB and perform CRUD operations are in empDBManager.jar. This jar is packaged in the root of application zip. So you don’t need to specify extra Classpath in All jars in the root of application folder are loaded. I have included Java source code also in this jar and also uploaded as

SQLite JDBC driver is in sqlitejdbc-v056.jar, which is also packaged in the application zip file. Classes in empDBManager use this JDBC driver.

Calling Java APIs for SQLite Database operations

Take a look at emp.js (again, in SQLiteApp,zip) to see how Database APIs in empDBManager.jar are called.

First, get path of the application (zip/folder)

appPath = getApplicationPath();

Next, if database file path is saved from the previous session, then get the path –

var dbPath = executeStaticJava("ram.kulkarni.war.sql.demo.SQLDemoUtils", "getSavedDBPath", appPath, null);

Note that SQLDemoUtils class is in empDBManager.jar.

Create/open DB file in createDB function –

var ret = createJava("ram.kulkarni.war.sql.demo.EmployeeDBManager", filePath, "empMgr");

The above function call creates an instance of EmployeeDBManager (by passing filePath as the argument to the constructor), which can be referenced as empMgr.

Save DB file path in a properties file after DB is created/opened

if (appPath && filePath)
    executeStaticJava("ram.kulkarni.war.sql.demo.SQLDemoUtils", "saveDBPath", appPath,filePath,null);

Notice above how SQLiteApp remembers last opened DB file in properties file using some of the new APIs added to WebAppRunner.

Add an employee –

//Create a new EmployeeVO object
var ret = createJava("ram.kulkarni.war.sql.demo.EmployeeVO", "empVO");
//Set properties of EmployeeVO
executeJava("empVO", "setFirstName", firstName, null);
executeJava("empVO", "setLastName", lastName, null);
executeJava("empVO", "setAddress", address, null);
//Call addEmployee on empMgr, passing empVO as argument
var id = executeJava("empMgr", "addEmployee", "$empVO", null);

I hope this example gives a glimpse of how you can create powerful database standalone applications using HTML/JS UI with Java backend.

-Ram Kulkarni

4 Replies to “Developing Database Applications with WebAppRunner”

Leave a Reply