Dec 29, 2008

How to install and run PHP 5 with Apache 1.x on Windows

Step 1 : Download PHP 5 from following link
PHP 5 Download

Step 2: Download Apache 1.3.x from following link
Apache 1.3.x Download

Step 3 : Install Apache 1.3.x download by running the msi file.

Step 4: On Server Information screen enter the following information
  1. Network Domain : localhost
  2. Server Name : localhost
  3. Administrator Email Address : abc@abc.com
  4. Select for All Users, on Port 80 radio button




Step 5 : Select Typical radio button and click next to install Apache Http Server.

Step 6 : Install PHP by clicking on the php msi installer

Step 7 : Select Apache 1.3.x Module as radio button option





Step 8 : Specify the location of the PHP installation.

Basic installation is done by following steps from 1 to 8. Now Apache needs to be configured for using PHP 5.

Step 1 : Open httpd configuration file which can be found at
\\Apache Software Foundation\Apache\conf

Step 2 : Enter the following LoadModule statement after series of LoadModule statement as shown below

LoadModule php5_module "c:/php/php5apache.dll"





Step 3 : Enter the following AddType statement after series of AddType statements as shown below

AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml





Step 4 : Enter the following ScriptAlias after ScriptAlias statement as shown below
ScriptAlias /php/ "c:/PHP/"





Step 5 : Test PHP configuration

Create PHP file as follows

test.php


Place this file under \\Apache Software Foundation\Apache\htdocs directory.

Start the Apache server and place http://localhost/test.php in browser.

If screen with php info is displayed then it mean that configuration is successful else there is something wrong somewhere.

Dec 26, 2008

Book Review : Jasper Report for Java Developers

I just finished reading Jasper Report for Java Developer written by David R. Heffelfinger and published by PACKT publishing and here is my review on the book.

The book is really a good read as far as I am concerned. I had never worked on the Jasper Reports earlier, so I can say that its a very good book for beginners . If you are a java developer and want to learn working on Jasper Reports fast I would recommend this as a first book about Jasper Reports.

For those who have never worked on java I would not recommend this as the first book as it requires some basic java understanding.

The book is divided into 11 chapters.

Chapter 1 and 2 are introductory chapter describing history of Jasper Report in general and what Jasper Report is all about. It also describes the environment setup required for using Jasper Reports.

Chapter 3 is the actually where you create your first report. It also provides some of the basics of Jasper Reporting.

Chapter 4 and 5 deals with generating reports by embedding sql queries in report and using different data sources like databases, XML, Java objects etc.

Chapter 6 is an important chapter of the book as provide knowledge about maintaining report layout and design. Sub reporting details are also provided in this chapter.

Chapter 7 and 8 details out step required for adding Chart and other graphic features to the report.

Chapter 9 is totally dedicated to export formats that are supported by Jasper Reports.

Chapter 10 describe how to create reports using IReport designer. IReport makes the designing of the report very easy and simpler. In earlier chapter whatever has been mentioned related to layout and designing of report are done by writing code in JRXML file of report, but using IReport designer its just drag and drop. Although its always good to know how its reflected at the actual jrxml file and how to create reports if designer is not available.

Chapter 11 is all about integrating of Jasper Report with other frameworks like Struts and Spring. These have been explained with simple example.

In the end I would like to recommend this book to all developers who want to learn or use Jasper Report. This book is written in easy to understand language with simple example which can be used for getting hands-on.

Book can be purchased from Packt publishing

Dec 16, 2008

Identifiers in Java

Some points about Identifiers
  1. A name in a program is called an identifier.
  2. An identifier is sequence of characters which can be a letter, digit, connecting characters (Underscore _) or a currency symbol ($, ¢, ¥ or £).
  3. Identifier cannot start with a digit, after first character digits are allowed.
  4. Identifiers in java are case sensitive i.e. test and Test are two different Identifiers.
  5. Identifier can be of any length
  6. Keywords cannot be used as an Identifier.

Illegal Identifier

  1. 45abcd – Starting with a digit
  2. abcd@efgh – @ is not allowed
  3. new – Keyword not allowed

Legal Identifier

  1. $$ – $ is allowed
  2. Ab88cd – Digits are allowed after first character.
  3. Abc_88 – Underscore is a valid connecting character.

Important Point about hash code

Important points about hash code
  1. Hash code is used for increasing the performance of large collection of data.
  2. Hash code is not always unique.
  3. Hash code only tell about the bucket to go into, but not how to locate the name once we are in that bucket.
  4. Collection use the hash code value of the object to decide in which bucket / slot the object should land.
  5. If two objects have same hash code value then it is not necessary that they are equal.
  6. Hashing is a two step process firstly search the right bucket using the hash code value, then search for the element in the bucket using equals()

equals() and ==

== operator evaluates to true, only when both references refer to the same object
e.g reference a------------> Object1
reference b------------> Object1
then a == b returns true.

  1. String class and Wrapper classes has override equals() method , so that two different objects could be compared to see if their contents are meaningfully equal.
  2. If classes equals() method is not overridden then it cannot be used as key in a Hashtable.
  3. equals() method in Object Class use only the == operator for comparison.
  4. If two objects are considered equal by using the equals() method then they should have identical hashcode values. So it is advisable to override hashCode() when equals() is overridden.

Dec 15, 2008

Basics of Java

Complexity can be handled by abstraction. In OOPS abstraction is modeled using Classes and objects.
A Class models abstraction by defining properties and behavior of an object.
Properties of an object are defined by the attributes, which are fields in java. A field in java is a variable that can hold value.
Behavior of an object is defined by the methods in java.

Object is an instance of the class. In java objects can only be manipulated using references.
Each Object created maintains its own copy of instance variables. Two objects can have same state if the values of their instance variable are same.
Object communicates with each other using message passing.

Static members/methods
  1. Certain members belong to Class only not to object these are called static members.
  2. A static member is initialized when the class is loaded at runtime.
  3. Certain methods that belong to the Class only and not to an object are called static methods.
  4. Client can access static methods using the class name.
  5. Static members of the Class can be accessed either using Object reference or using Class name.
Example of Class & Object
package Test;
//Class declaration
public class Example_Class {
//Attribute declaration - These variables defines the state of the object
private int first_attribute;
private int second_attribute;
//constructor
public Example_Class(int x, int y) {
//Initializing attributes of newly created object.
this.first_attribute = x;
this.second_attribute =y;
}
//Method - These methods define the behavior of the object
public int addResult() {
return first_attribute + second_attribute;
}
//Main method of Class
public static void main(String[] args) {
/* Object instantiation - Object is created using "new" keyword With new keyword Constructor of the class is called which returns the reference of the newly created object, which is assigned to
reference variable of appropriate Class.
*/
// objFirst ---------> Object1(1,2)
Example_Class objFirst = new Example_Class(1, 2);
//Both objFirst and objSecond object refernces will point to two different objects in heap
// objSecond ---------> Object2(1,2)

Example_Class objSecond = new Example_Class(1, 2);
int addResultFirst = objFirst.addResult();
System.out.println("Add Result First:" + addResultFirst);
//Calling method on second created Object
int addResultSecond = objSecond.addResult();
System.out.println("Add Result Second:" + addResultSecond);
}
}

Nov 29, 2008

Installing & using SoapUI


Steps for installing and using SoapUI are as follows
  1. Install the Soap UI plug-in in eclipse or WebLogic Workshop
  2. Go to the Help > Software Updates > Find & Install
  3. Select for "Search for new features to install".
  4. Click Next button
  5. Click on "New Remote Site".
  6. Enter the name : SoapUI
  7. Enter url: http://www.soapui.org/eclipse/update/site.xml
  8. Click Finish
  9. SoapUI plug-in will be installed on system.
  10. After installation is complete, restart the workshop
  11. Go to Window > Open Perspective > Other
  12. Select SoapUI
  13. Right click on Project Icon on the left and create "New WSDL Project"
  14. Enter the project name
  15. Enter the WSDL location
  16. Click OK button
  17. Project will be created with entered name and all the projects exposed by WSDL will be visible under the + sign
  18. Click on + sign to view all the methods
  19. Double click on the method you want to test and click on Request 1 icon
  20. Enter the inputs required by the method and click on green play button on the top left.
  21. Based on entered input Response is generated on right pane.


Important Points about Threads in Java


  1. To synchronize threads, the Java programming language uses monitors, which are a high-level mechanism for allowing only one thread at a time to execute a region of code protected by the monitor.
  2. The behavior of monitors is explained in terms of locks; there is a lock associated with each object.
  3. The methods wait, notify, and notifyAll of class Object support an efficient transfer of control from one thread to another.
  4. A thread can suspend itself using wait until such time as another thread awakens it using notify.
  5. Each thread has a working memory, in which it may keep copies of the values of variables from the main memory that is shared between all threads.
  6. To access a shared variable, a thread usually first obtains a lock and flushes its working memory. This guarantees that shared values will thereafter be loaded from the shared main memory to the threads working memory.
  7. When a thread unlocks a lock it guarantees the values it holds in its working memory will be written back to the main memory.
  8. Every thread has a working memory in which it keeps its own working copy of variables that it must use or assign. As the thread executes a program, it operates on these working copies. The main memory contains the master copy of every variable.
  9. The main memory also contains locks; there is one lock associated with each object. Threads may compete to acquire a lock.

Jul 25, 2008

Finalization in Java

protected void finalize() throws Throwable

  1. It is declared in Object class.
  2. Is invoked by the garbage collector after it determines that this object is no longer reachable and its space is to be reclaimed.
  3. finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized.
  4. Subclasses of Object may override this definition.
  5. It is guaranteed that the thread that invokes finalize() will not be holding any user-visible synchronization locks when finalize() is invoked.
  6. Any exception thrown by the finalize() causes the finalization of this object to be halted, but is otherwise ignored.
  7. finalize() is invoked at most once per object, even if execution of this method causes the object to become reachable again and later it becomes unreachable again.

Feb 16, 2008

ENUMS in Java

Some Important points about Java Enums.
  1. Enums can be declared as their own separate class, or as a class member, however they must not be declared within a method.
  2. Enums can be declared outside the class.
  3. Enums cannot be private or protected.
  4. Enums can have only default or public modifier.
  5. Semicolon at the end of Enums declaration is optional.
  6. Enum is a special type of Class.
  7. Enum constructor are never invoked directly
  8. Enum constructor can be overloaded just like any other constructor in class.
  9. If an enum is declared as public then it should be declared in its own file.
  10. Enums declared within a class can have public, private, protected, default, static and abstract modifiers

package TechnicalTutorial;

/* Enum declared outside the class can have default access only */

enum TechEnum{
FIRST, SECOND, THIRD
}

public class Example_1 {

public enum TechEnum_2{
HUNDRED, THOUSAND
}

public static void main(String[] args) {
TechEnum num = TechEnum.FIRST;
System.out.println(num);

}
}

In above example enum can be declared as public only within a Class i.e. TechEnum_2 . If an enum need to be declared as public outside the class then it should be created in separate file.

Jan 14, 2008

Book Review : Business Process Management with Jboss JBPM

Currently I am working on a project that involves jBPM as the workflow engine and jPDL as the design language. Recently I had gone through a review copy of book Business Process Management with JBoss jBPM, written by Matt Cumberlidge and published by PACKT Publishing and here is the review on the book as per terms of review copy.

The book is good introduction into the JBPM, primarily for Business Analysts and architects. For developers it is useful guide that highlights the correct approach that should be followed before implementing a BPM solution.

Things I liked about the book:

Firstly, the book actually delivers what it says: providing a good introduction into the jBPM world. It can be followed as hands on book by business analyst and beginners can follow it as a tutorial for quick start.

All the features of jPDL designer are explained step by step with properly supporting images. Images always put information more intuitively. Initial chapter of the book talk about the environment setup which includes installation of each and every software.

Book follows one example approach, linking whole software development lifecycle and how BPM fits in it, although I personally would have liked some small examples also.

Things I didn’t like about the book:

There are more than a couple of things that I didn’t like about the book. The book doesn’t dive deep into the technical aspect of the jBPM. The book is more on theoretical side with only one example explained through out the book. Some of the technical stuff related to sub process and super states was too concise. The book was not thoroughly enough for developers.

Conclusion

I would recommend this book to newbie’s who wants to learn about JBPM and BPM. From developer’s point of view it does not provide answer to actually create an enterprise level application although it is good book for beginners.

The book can found at Packt Publishing