Skip to main content


Showing posts from May, 2011

Log4j - Email errors using Gmail

Most of the small projects doesn't have a dedicated person to monitor log file all the times, and its handy to send these errors as email to an email list.


Never miss an error.Delete Emails which you want to ignore because of invalid inputs or connectivity issues etc.Proactively identify bugs and fix them.Email list is handy i.e. multiple person can receive emails.If you have different modules in your project and different teams work on them, adding a Labels to your log can by handy since most of the Email Servers can Label emails and redirect them to different folders.Cons    Sending email from code takes few seconds, workaround is the create Logger wrapper which logs in a separate thread.
log4j.rootLogger=ERROR, gmail…

Data Types in Java

Session 1 - Data Types in Java
What is Data ?
 Most of you have shopped online and this is what a typical purchase looks like

    You select a product which has a Price, Tax, Quantity    You pay using your Credit Card by entering Name, CC Number, Expiration Date, Billing    Address, ZipcodeWords above in Bold are data.

What is then Data Type ?    Can we say Price, Tax, Quantity is of type Number because we can apply Arithmetic (+, -, /, *, %) Operations on them, i.e. we multiply Price & Quantity and than add Tax.
Similarly Your Name, Address are text because it doesn't make sense to have Arithmetic Operation on them and in Java we call them String.

Supported Data Types in Java   String   -  Text   double  - Real Numbers i.e. 33.2, 20.0 etc   int         - Non-Real Numbers i.e. 10, 30, 3453 etc

Typical Java Programs using the above Data Types
public class DataTypesDemo {     public static void main(String[] args) {

        // define a Data Variable message of type String         String mes…

How I teach Java in 1hr 5 sessions

I know a lot of people can disagree with this but I am trying to keep it simple and as only my own opinion.

It took me more than 5 yrs to design this syllabus to help beginners learn and get motivated to program in Java. When I started teaching I use to take 10-15 days to teach java and I can clearly see on participants faces that they were not confident even after spending so much time with them. However recently I was able to successfully use a shorter And I am sure this won't be the final one and it will change a lot after few more batches. And the only way I do this is by
focusing on important concepts and cutting dumb one's in a language to accomplish my objectives.

Session 1
  Data Types (int, double, String )  Class Notes  Operators (Arithmatic - +,-,*,/ )  Functions  Homework -

 Write 50 functions and execute them from main method             Write functions with 0 or more input parameters Write functions that returns a value

Session 2 (Point here is to introduce Objects e…

How to Schema Validate Metro SOAP Request

@SchemaValidation does the trick checkout the sample code below

package com.palm.appstore.wsc;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

* @author Intesar Mohammed
@WebService(serviceName = "Echo")
public class Echo {

    /** This is a sample web service operation */
    @WebMethod(operationName = "hello")
    public String hello(@WebParam(name = "no") int txt) {
        return "Hello " + txt + " !";

Valid Request
<soapenv:Envelope xmlns:soapenv="" xmlns:wsc="">

<S:Envelope xmlns:S="…