Creating an enterprise application project in Eclipse (J2EE)

Enterprise application projects contain references to the resources needed for enterprise applications and can contain a combination of Web modules, JAR files, connector modules, EJB modules, and application client modules. An enterprise application project is deployed in the form of an EAR file, and is therefore sometimes referred to as an EAR project. The modules in an enterprise application project are mapped to other J2EE projects. The mapping information is stored in metadata files within the enterprise application project. The metadata files are used for exporting the project to an EAR file and for running the project on the server.

Like the other types of projects, enterprise application projects can contain one or more project facets, which represent units of functionality in the project. To be deployed as an EAR file, the new project must have the EAR facet. Depending on what you want to use the project for, you may want to enable other facets for the project.

When you create an enterprise application project, it is recommended that you do not give it a name that contains double-byte character set (DBCS) characters.

To create a J2EE enterprise application project:

1. In the J2EE perspective, click File > New > Project > J2EE > Enterprise Application Project.
2. In the Project Name field, type a name for the new project.
3. To change the default project location, clear the Use default check box under Project contents and select a new location with the Browse button.
4. In the Target runtime field, select the target runtime for the project. You can click the New button to create a new runtime for the project to use.
5. If you want to use a predefined configuration for your project, select a configuration in the Common Configurations list.
6. Click Next.
7. Select the check boxes next to the facets you want this project to have and select a version number for each facet. You can also choose a preset combination of facets from the Presets list, and you can also find out more about the requirements for each facet by right-clicking the facet name and then clicking Show Constraints.
8. If you want to limit your project so it will be compatible with one or more runtimes, click the Show Runtimes button and select the runtimes that you want the project to be compatible with.
9. Click Next.
10. On the J2EE Modules to Add to the EAR page of the wizard, select the existing modules that you want to add to the new enterprise application project.
11. You can also create new modules to add to the project:
1. Click the New Module button.
2. If you want to create one module, clear the Create default modules check box, select the type of module you want to create, click Next and follow the New Project wizard for that type of project.
3. If you want to create more than one module, select the Create default modules check box, select the check boxes for each type of project you want to create, and click Finish. You can enter a name for each module. Each of these modules will have the default settings for that type of project and they will have the same server target as the new enterprise application.
12. Click Finish.


iBasic : Object Oriented Programming

Object Oriented Programming

OOP: Object oriented programming as an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand.

Striking features of object-oriented programming are :

  • Emphasis is on data rather than procedure.
  • Programs are divided into what are known as objects.
  • Data is hidden and cannot be accessed by external functions.
  • Objects may communicate with each other through functions.
  • New data and functions can be easily added whenever necessary.
  • Follows bottom-up approach in program design

Basic concepts of object-oriented programming:

  • Objects
  • Classes
  • Data abstraction and encapsulation
  • Inheritance
  • Polymorphism
  • Dynamic binding
  • Message passing

Objects: An object is considered to be a partitioned area of computer memory that stores data and set of operation that can be access the data. Object are the basic run-time entities in an object-oriented system. It represents s physical/real entity.

Classes: Classes are user-defined data types and behave like the built-in types of a programming language. Class is concrete representation of an entity. It represents a group objects, which hold similar attributes and behavior. It provides abstraction and encapsulation.

Encapsulation: The wrapping up of data and functions into a single unit(called class) in known as encapsulation. Encapsulation is binding of attributes and behaviors. Hiding the actual implementation and exposing the functionality of any object. Its main aim is to protect the data from outside world.

Abstraction: Abstraction refers to the act of representing essential features without including the background details or explanations. Hiding the complexity.

Polymorphism: Means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends upon the types of data used in the operation. Ability to provide different implementation based on different number/type of parameters.

Pure-Polymorphism: When a method is declared as abstract/virtual method in a base class and which is overridden in a base class. If we create a variable of a type of a base class and assign an object of a derived class to it. It will be decided at a run time, which implementation of a method is to be called. This is known as Pure-Polymorphism or Late-Binding.

Overloading: Adding a new method with the same name in same/derived class but with different number/types of parameters. It implements polymorphism.

Overriding: A process of creating different implementation of a method having a same name as base class, in a derived class. It implements Inheritance.

Shadowing: When the method is defined as Final/sealed in base class and not override able and we need to provide different implementation for the same. This process is known as shadowing, uses shadows/new keywords.

Dynamic binding: Means that the code associated with a given procedure call is not known until the time of the call at run-time. It is associated with polymorphism and inheritance.

Inheritance: It is a process of acquiring attributes and behaviors from another object(normally a class or interface).

Abstract class: An abstract class is a special kind of class that cannot be instantiated. It normally contains one or more abstract methods or abstract properties. It provides body to a class.

Interface: An interface has no implementation. It only has the signature or in other words, just the definition of the methods without the body.

Constructor: A special function always called whenever an instance of the class is created.

  • Same name as class name
  • No return type
  • Automatically call when object of class is created
  • Used to initilize the members of class

Copy Construction: Constructor which initializes it’s object member variables (by shallow copying) with another object of the same clas

Test t1(10); // calling Test constructor

Test t2(t1); // calling Test copy constructor

Test t2=t1; // calling Test copy constructor

Destructor: A special method called by GC. Just before object is being reclaimed by GC.

Method Overloading: Method overloading is having methods with same name but carrying different signature, this is useful when you want a method to behave differently depending upon a data passed to it.

Static assembly: Static assemblies can include .NET Framework types (interfaces and classes) as well as resources for the assembly (bitmaps, JPEG files, resource files, and so forth). Static assemblies are stored on disk.

Dynamic assembly: Dynamic assemblies run directly from memory and are not saved to disk before execution.

Functionality of an assembly:

  • It is the smallest unit that has version control.
  • All types and resources in the same assembly are versioned as a unit and support side by side execution.
  • Assemblies contain the metadata and other identities which allow the common language runtime to execute.
  • They are the unit where security permissions are requested and granted.

Serialization: Serialization is the process of converting an object into a stream of bytes.

De-serialization: De-Serialization is the opposite process of creating an object from a stream of bytes.

Serialization/De-serialization is mostly used to transport objects (during remoting), or to persist objects (e.g. to a file or database).

  • XmlSerializer [for webservices]
  • SoapFormatter/BinaryFormatter [for remoting

Advantages of Inheritance:

  • It permits code re-usability.
  • Re-usability saves time in program development.
  • It encourages the reuse of proven and debugged high-quality software, thus reducing problem after a system becomes functional.
OOP: Object oriented programming as an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand.

Installing tomcat on ubuntu

Installing Tomcat on Ubuntu
Before you install Tomcat you’ll want to make sure that you’ve installed Java. I would assume if you are trying to install Tomcat you’ve already installed java, but if you aren’t sure you can check with the dpkg command like so:

dpkg –get-selections | grep sun-java

This should give you this output if you already installed java:

sun-java6-bin install
sun-java6-jdk install 

If that command has no results, you’ll want to install the latest version with this command:

sudo apt-get install sun-java6-jdk

Now we’ll download and extract Tomcat from the apache site. You should check to make sure there’s not another version and adjust accordingly.

tar xvzf apache-tomcat-6.0.14.tar.gz 

The best thing to do is move the tomcat folder to a permanent location. I chose /usr/local/tomcat, but you could move it somewhere else if you wanted to.

sudo mv apache-tomcat-6.0.14 /usr/local/tomcat

Tomcat requires setting the JAVA_HOME variable. The best way to do this is to set it in your .bashrc file. You could also edit your file if you so chose.

The better method is editing your .bashrc file and adding the bolded line there. You’ll have to logout of the shell for the change to take effect.

vi ~/.bashrc

Add the following line:

export JAVA_HOME=/usr/lib/jvm/java-6-sun

At this point you can start tomcat by just executing the script in the tomcat/bin folder.