Bell Eapen

Physician | HealthIT Developer | Digital Health Consultant

Deploying Java applications with embedded derby database

Ruby on Rails
Ruby on Rails (Photo credit: Wikipedia)

I have been trying to brush up my programming skills during the christmas break. I recently added the tagline “Dermatologist who codes” to my elevator speech. My plan is to sharpen my java skills and to learn python and ruby on rails. I believe coding real world applications is the best way to learn/sharpen any programming language.

Here is the first innovative application, Dermatology Image Tagger that I made. I believe this would be quite useful to dermatologists for organizing clinical images. Afterwards I made a simple java database application for a colleague. I never explored the deployment of java applications before. I hit google to find useful resources, but found only very few. The one I found most useful was Aparna’s blog. Here she succinctly explains how to use the Java embedded derby database. The only thing I had to figure out the hard way was to use the connection string as below to force creation of the database in the working directory. I also added a ‘create table’ button for initial deployment.

 String host = “jdbc:derby:imfdb;create=true”;
            String uName = “your_username”;
            String uPass= “your_password”;
            con = DriverManager.getConnection(host, uName, uPass);
            stmt = con.createStatement();

She has also written an very useful article on deploying java desktop applications. I followed her instructions to package all required files into a single executable jar file for Mac and an exe file for windows. I have used this for DIT. Thanks Aparna for making life easy for me!

Pink in honor of breast cancer awareness programs
Pink in honor of breast cancer awareness programs (Photo credit: beapen)

I am still exploring python and Ruby on Rails. So far I have been really impressed by the way Ruby on Rails managed to make web application development intuitive. I also learnt git for version tracking and joined github. I have added few learning projects for python and RoR that may be useful applications if developed properly. Feel free to fork, watch or star them and if you are on github too, a follow will not hurt.

So this will be my last post for 2013. Will meet you all again in 2014.

Running Tomcat as www-data

For last couple of days I have been working on a web based application for skin color measurement as I blogged here. The core of the application is implemented in php as it is much easier to handle. (May be I am more comfortable with it). But the GD image library for php has limited functionality. So I had to rely on Java for border detection and segmentation. So I implemented part of the functionality as a servlet running on tomcat6.

Today's latte, Apache Tomcat.
Today’s latte, Apache Tomcat. (Photo credit: yukop)

Both php and servlet had to read and write same files. But standard configuration does not allow this as php creates files as www-data (apache user) and tomcat creates files as tomcat6 user. I searched the internet for solutions. One suggestion was to create an appropriate umask for both which I could never completely understand. Finally I realised that the easiest solution is to make tomcat run as user www-data so that all created files will have same ownership.

I found this webpage with detailed instructions on how to do this. I would like to add two more steps:
1. Edit /etc/init.d/tomcat6 also to add the user ID and group ID
2. chown var/cache/tomcat6 directory also.

Nina Jablonski - The Evolution of Human Skin Color
Nina Jablonski – The Evolution of Human Skin Color (Photo credit: wagnerfreeinstitute)

BTW the application is hosted on my laptop. If you want to check it out click on the banner below if you see it. You will see it only when my laptop is on.