Friday, 29 November 2013

Exception handling in Java :

The exception handling is one of the powerful mechanism provided in java. It provides the mechanism to handle the runtime errors so that normal flow of the application can be maintained. An exception is a problem that arises during the execution of a program. An exception can occur for many different reasons, including the following:

   - A user has entered invalid data.

   - A file that needs to be opened cannot be found.

   - A network connection has been lost in the middle of communications or the JVM has run out of memory.

Some of these exceptions are caused by user error, others by programmer error, and others by physical resources that have failed in some manner. Java exception handling enables your Java applications to handle errors sensibly. Exception handling is a very important yet often neglected aspect of writing robust Java applications or components. When an error occurs in a Java program it usually results in an exception being thrown. How you throw, catch and handle these exception matters. There are several different ways to do so. Not all are equally efficient and fail safe. 

To understand how exception handling works in Java, you need to understand the three categories of exceptions :

   1. Checked exceptions : A checked exception is an exception that is typically a user error or a problem that cannot be foreseen by the programmer. For example, if a file is to be opened, but the file cannot be found, an exception occurs. These exceptions cannot simply be ignored at the time of compilation. The classes that extend Throwable class except RuntimeException and Error are known as checked exceptions e.g.IOException, SQLException etc. Checked exceptions are checked at compile-time. 

   2. Runtime exceptions : A runtime exception is an exception that occurs that probably could have been avoided by the programmer. As opposed to checked exceptions, runtime exceptions are ignored at the time of compilation. The classes that extend RuntimeException are known as unchecked exceptions e.g. ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException etc. Unchecked exceptions are not checked at compile-time rather they are checked at runtime. 

   3. Errors : These are not exceptions at all, but problems that arise beyond the control of the user or the programmer. Errors are typically ignored in your code because you can rarely do anything about an error. For example, if a stack overflow occurs, an error will arise. They are also ignored at the time of compilation. Error is irrecoverable e.g. OutOfMemoryError, VirtualMachineError, AssertionError etc.

Exception Hierarchy :

All exception classes are subtypes of the java.lang.Exception class. The exception class is a subclass of the Throwable class. Other than the exception class there is another subclass called Error which is derived from the Throwable class. Errors are not normally trapped form the Java programs. These conditions normally happen in case of severe failures, which are not handled by the java programs. Errors are generated to indicate errors generated by the runtime environment. Example : JVM is out of Memory. Normally programs cannot recover from errors.
The Exception class has two main subclasses: IOException class and RuntimeException Class.

Exceptions Methods :

Following is the list of important medthods available in the Throwable class.

SN Methods with Description

1 public String getMessage()      Returns a detailed message about the exception that has occurred. This message is  initialized in the Throwable constructor.

2 public Throwable getCause()     Returns the cause of the exception as represented by a Throwable object.

3 public String toString()        Returns the name of the class concatenated with the result of getMessage()

4 public void printStackTrace()   Prints the result of toString() along with the stack trace to System.err, the  error output stream.

5 public StackTraceElement[]getStackTrace()  Returns an array containing each element on the stack trace. The  element at index 0 represents the top of the call stack, and the last element in  the array represents the method at the bottom of the call stack.

6 public Throwable fillInStackTrace()    Fills the stack trace of this Throwable object with the current stack  trace, adding to any previous information in the stack trace.

Catching Exceptions :

A method catches an exception using a combination of the try and catch keywords. A try/catch block is placed around the code that might generate an exception. Code within a try/catch block is referred to as protected code, and the syntax for using try/catch looks like the following:

   //Protected code
}catch(ExceptionName e1)
   //Catch block

A catch statement involves declaring the type of exception you are trying to catch. If an exception occurs in protected code, the catch block (or blocks) that follows the try is checked. If the type of exception that occurred is listed in a catch block, the exception is passed to the catch block much as an argument is passed into a method parameter.

finally block :

The finally block is a block that is always executed. It is mainly used to perform some important tasks such as closing connection, stream etc. The finally keyword is used to create a block of code that follows a try block. A finally block of code always executes, whether or not an exception has occurred. Using a finally block allows you to run any cleanup-type statements that you want to execute, no matter what happens in the protected code.

A finally block appears at the end of the catch blocks and has the following syntax:

   //Protected code
}catch(ExceptionType1 e1)
   //Catch block
}catch(ExceptionType2 e2)
   //Catch block
}catch(ExceptionType3 e3)
   //Catch block
   //The finally block always executes.

The throws/throw Keywords :

If a method does not handle a checked exception, the method must declare it using the throws keyword. The throws keyword appears at the end of a method's signature. You can throw an exception, either a newly instantiated one or an exception that you just caught, by using the throw keyword. Try to understand the different in throws and throw keywords. The throw keyword is used to explictily throw an exception. We can throw either checked or uncheked exception. The throw keyword is mainly used to throw custom exception.

Declaring you own Exception :

You can create your own exceptions in Java. Keep the following points in mind when writing your own exception classes:

   - All exceptions must be a child of Throwable.

   - If you want to write a checked exception that is automatically enforced by the Handle or Declare Rule, you need to extend the Exception class.

   - If you want to write a runtime exception, you need to extend the RuntimeException class.

We can define our own Exception class as below:

class MyException extends Exception{ }

You just need to extend the Exception class to create your own Exception class. These are considered to be checked exceptions. The following InsufficientFundsException class is a user-defined exception that extends the Exception class, making it a checked exception. An exception class is like any other class, containing useful fields and methods.

Common Exceptions:

In Java, it is possible to define two catergories of Exceptions and Errors.

   - JVM Exceptions: - These are exceptions/errors that are exclusively or logically thrown by the JVM. Examples : NullPointerException, ArrayIndexOutOfBoundsException, ClassCastException,

   - Programmatic exceptions: - These exceptions are thrown explicitly by the application or the API programmers Examples: IllegalArgumentException, IllegalStateException.

Exception handling in Java, Exceptions Methods, try/catch/finally blocks in Exception handling.


Preeti Bagad [BE(CS)] 
SW Engineer Cum Blogger

On Line Assistence :
Y! Messenger :

Thursday, 3 January 2013

Java Training and Tutorials, Core Java Training

Introduction to Online Java Tutorials for new Java Programmers.

Java is a powerful object-oriented programming language with simple code structure. You can create applications and applets with graphics and user interfaces because Java has built-in application programming interface (API) and due to its rich set of interfaces java has a platform in itself. Java provides errorless programming with platform independent feature. Java developers tried to write the code structure similar to the syntax of C++ so it would be easy for C++ programmers to learn java. In comparison to C++, Java handles many operation like creation and deletion of memory automatically, it helps to make bug-free code in Java application.

View Online Java Training Schedule
View Core Java Training course
The course we offered is designed and centered for new programmers. We provides you the course materials with extreme knowledge-full examples prepared by Java professionals. It makes you perfect in Java programming as well as  for being a successful software professional. Here we also provides topic based examples with description in more generic way.

We prepare the course which covered all the topic of Java with point of view of Java professionals. We also keep in mind the topic which covered by sun-certification and try to make you perfect for certification. We covered all necessary topic of object-oriented programming in Java and this is the strong reason for you to trust our courses. The course we provides you is often easy to understand the concept of object-oriented programming because all the chapters are further divided in more topic.

Java Tutorial Beginner
Photoshop Tutorials
Free Microsoft Outlook Tutorials
Free Visual Basic Tutorials
Paint Shop Pro Tutorials
Free Online Quickbooks Tutorial
PSP Tutorials
Free Photoshop Elements Tutorials


Thursday, 13 December 2012

Java Projects and Mini Projects For Engineering Students

Java is a computer programming language that was created by Sun Microsystems. Java is mainly used on the internet, and it uses a virtual machine that has been executed in many browsers for translating Java into a special app on various computers. With most computer programming languages, you need to either interpret or compile a program in order to run it on the computer. Java is different in this which is both compiled as well as interpreted. Most of the Java programs are applications or applets. Java applications are objective programs, for example HotJava browser. Applets are also similar to applications, but they do not work individually. Instead, they stick to a group of conventions which lets the applets run in a Java-compatible browser.

Following are some project ideas on Java:

        Puyo game
        Country Guessing Game
        Bus Scheduling and Booking System
        Dice Application System
        Medical Diagnostic System
        Beat it Game
        Recruitment Officer System

        Online courses
        Online Yearbook with SMS
        Bluetooth multiplayer game
        Library Information System
        Online Address Book
        Online library
        Mexican game
        Banker Database System
        Online shoping
        RPG Battle Demo
        Graphical Library System
        Airways reservation system
        Drag Drop Board Game Template
        Scheduler System
        Evaluation System
        Telephone Billing System
        Result Intimation System
        Graphical Payroll System
        Java Exam System
        Asteroids java applet
        Online exam
        Online Remote Server
        Student Counseling Management System
        Belle Boutique POS System

 java projects

java programs

java tutorial

java projects with source code and documentation free download

Overview of Client tier, Presentation tier, Business tier, and Resource tier patterns

Java originally made its debut on client machine and browser. With increasing third party support in java 2 , J2EE (Java 2 Enterprise Application ) technology is widely being accepted for server side enterprise applications. J2EE architecture is logically divided in to many tiers such as client tier, presentation tier, business tier, and database tier. It supports many APIs and protocol that provides the functionality to provide multi tier web application.

J2EE Client Tier

J2EE application supports many types of clients they can run on laptop, desktop, palmtop, or on cell phone. They may range from desktop big browser to cell phone mini browser, all they connect to world wide web from their intranet, through a wired network or wireless network.

Java client tier consists of application running on desktop, laptop etc  and they connect to the application server directly using HTTP, FTP etc protocol. This requires only that the application must installed on the client machine. The web browser is the client application software used to connect to the application server.

J2EE Presentation Tier

A J2EE presentation tier consists of applications that prepare /format data to deliver the client tier, and and takes data from client side  to send back end business process. This tier typically consists of J2EE components such as servlet, JSP that prepare data in HTML or XML  to deliver to the client. This tier also provides portal services that can provide secure, customize and personalize  business service.

The presentation tier components are often reusable components that can be customized and plugged into an application.

Business Tier

The business tier performs the main function of the application by implementing the business logic on the data processing, coordinating among multiple user and managing database resources. This tier consists of tightly coupled components such as EJB components or message driven beans. It performs the business work and send to the presentation tier for client side or send to the database tier or data tier. The EJB can be used to solve business logic, and it is used to create business object .

Resource Tier/ Data tier

This tear consists all the data/ information related to the business logic. The data may be be resource or directory information stored in Lightweight Directory Protocol or it can be persistent application data stored in the database management system. Generally the data-tier is installed on the separate machine. All the information stored on this tier are very important for organization so it may kept to another place.

 java architecture

java architecture tutorial

java architecture interview questions

Tuesday, 11 December 2012

An Introduction to the Java Programming Language History of Java

Every great Dream begins with a Dreamer. 
Always remember, you have within you the 
Strength, the Patience, and the Passion 
to reach for the 
Stars to change the World.

java programming
java games
learn java
java script
java 64 bit
java update
java tutorial
java api

An Introduction to the Java Programming Language

History of Java 

In 1991, a group of Sun Microsystems engineers led by James Gosling decided to
develop a language for consumer devices (cable boxes, etc.). They wanted the
language to be small and use efficient code since these devices do not have
powerful CPUs. They also wanted the language to be hardware independent since
different manufacturers would use different CPUs. The project was code-named
These conditions led them to decide to compile the code to an intermediate
machine-like code for an imaginary CPU called a virtual machine. (Actually, there
is a real CPU that implements this virtual CPU now.) This intermediate code
(called bytecode) is completely hardware independent. Programs are run by an
interpreter that converts the bytecode to the appropriate native machine code.
Thus, once the interpreter has been ported to a computer, it can run any
bytecoded program.
Sun uses UNIX for their computers, so the developers based their new language
on C++. They picked C++ and not C because they wanted the language to be
object-oriented. The original name of the language was Oak. However, they soon
discovered that there was already a programming language called Oak, so they
changed the name to Java.
The Green project had a lot of trouble getting others interested in Java for smart
devices. It was not until they decided to shift gears and market Java as a language
for web applications that interest in Java took off. Many of the advantages that
Java has for smart devices are even bigger advantages on the web.
Currently, there are two versions of Java. The original version of Java is 1.0. At
the moment (Nov. 1997), most browsers only support this version. The newer
version is 1.1 (in addition 1.2 is in beta). Only MS Internet Explorer 4.0 and Sun's
HotJava browsers currently support it. The biggest differences in the two versions
are in the massive Java class libraries. Unfortunately, Java 1.1 applets will not run
on web browsers that do not support 1.1. (However, it is still possible to create
1.0 applets with Java 1.1 development systems.)
Basics of Java Applications

There are 2 basic types of Java applications:
These run as a normal program on the computer. They may be a simple
console application or a windowed application. These programs have the
same capabilities of any program on the system. For example, they may read
and write files. Just as for other languages, it is easily to write a Java console
program than a windowed program. So despite the leanings of the majority
of Java books, the place to start Java programming is a standalone console
program, not an applet!
These run inside a web browser. They must be windowed and have limited
power. They run in a restricted JVM (Java Virtual Machine) called the
sandbox from which file I/O and printing are impossible. (There are ways
for applets to be given more power.)
Development Tools
There are many development tools for Java:
Sun's JDK
Sun's Java Development Kit has two big advantages:
1. It is the most up to date.
2. It is free!
Its main disadvantage is that it only includes command line tools, no IDE. Many
Java books include this on a CD-ROM.
Borland's JBuilder
It contains an IDE and supports Java 1.1
MS Visual J++
It contains an IDE, but to my knowledge does not yet support Java 1.1
Symantec's Visual Cafe
It contains an IDE, but no Java 1.1 support yet.
Compiling and Running a Java Standalone Application
Hello, Java program
Here is a short Java program:
/* A simple Java program */public class Hello {
  public static void main( String args[] )
    System.out.println("Hello, Java");
Creating a Java source file
Java source files must end in an .java extension. The root name must be the same
as the name of the one public class in the source file. In the program above, the
class is named Hello and thus, the file must be named (Yes, case is
Just as for other languages, any text editor can be used to save the text of the
program into a text file.
Compiling a Java source file
Sun's JDK includes a Java compiler named javac. To compile the above Java
program one would type:
If successful, this creates a file named Hello.class If not successful, it prints out
error messages like other compilers.
Running a Java program
To run a standalone program, Sun's JDK provides a Java interpreter called java.
To run the .class file created above, type:
java Hello
Note that .class is not specified!
The output of running the above program is simply:
Hello, Java

Java Programming 

Classes and objects
Java is an object-oriented language (like C++). An object is an abstract thing in a
program. Generally, objects are not completely different from each other and can
be classified into like groups. The group an object belongs to is called a class.
Objects in the same class share two attributes:
1. A state space (i.e., the set of all possible states of the object)speak).
Consider the Vector class that the Java class library provides. A Vector object is
basically an array that grow or shrink in size dynamically. It's state is defined by:
1. The elements stored in their given order
2. The number of elements stored
It's methods include:
Adds an element to end of the vector increasing its size by 1
Adds an element at a specified position in the vector. The elements above
are shifted up one position and the size is increased by 1.
Stores an element at a specified position in the vector. The previous element
value is lost.
Removes an element at a specified position. The elements above are shifted
down and the size is decreased by 1.
Returns the element at a specified position.
Returns the current size of the vector.
If v is an object of type Vector, then a method is invoked on v by the following
For example, to add another object x to the end of v use:
In an object-oriented language, one looks at the statement above as a request for
the v object to add the object x to the end. That is, invoking a method sends a
message to the object being acted on. The message asks the object to perform
some operation.

Primitive types 
Java also supports some primitive types that are not classes. These types are
similar to the primitive types of C:
a single byte (8-bit) signed integer
a two-byte (16-bit) Unicode character
a two-byte (16-bit) signed integerint
a four-byte (32-bit) signed integer
an eight-byte (64-bit) signed integer
a four-byte floating point number
an eight-byte floating point number
a type of variable that may be either true or false
Defining a class 
The general form of a class definition is:
public class class-name {
  /* class state definitions */
  /* class method definitions */
Here's an actual example that creates a Queue class:
public class Queue {
   * the state of the Queue is represented by an internal vector instance
   * (The private indicates that this part of the Queue is only
   * accessible by the methods of the Queue class. This implementation
   * hiding is known as encapsulation.)
  private Vector v;
   * This is a constructor - it is used to create a new instance of
   * a Queue. The public indicates that this method is available for
   * use by any class.
  public Queue( )
    v = new Vector();      // construct the internal vector object
   * This method adds an element to the queue
  public void enque( Object obj )
    v.addElement(obj);     // add to end of internal vector  }
   * This method removes and returns an element from the queue
  public Object deque( )
    if ( v.size() > 0 ) {
      Object obj = v.elementAt(0); // read object from front of vector
      v.removeElementAt(0);        // remove object from front of vector     
      return obj;                  // return object
      return null;                 // if queue empty, return special null value
   * This method returns the number of elements in the queue
  public int size()
    return v.size();               // return size of internal vector
Using classes

To create an instance of a class, the instance must be constructed by a special
method called a constructor. Constructor methods always have the same name as
the class. To create a queue, one would type:
Queue q = new Queue();
The new keyword says to create a new object. The instance variable q can be used
to refer to this object. Thus, the statement:
says to enque the string "one" in the Queue referred to by q.
It is often stated that Java does not have pointers and technically this is true.
However, class reference variables act like pointers (or really more like reference
variables in C++). Assigning class instance variables do not create new instances.
For example:
  Queue q1 = new Queue();     // q1 refers to created Queue object
  Queue q2 = q1;              // both q1 and q2 refer to *same* object!
  q2.enque("two");  System.out.println((String) q2.deque() );   // prints out "one", not "two"
Non-class instance variables (like int variables) work just as in C, assignment
does copy values of these.
These rules have important consequences for parameters of methods. For
example, consider the following method call and code:
  // method call
  int x = 5;
  Queue q = new Queue();
  // method code
  void method( int xp, Queue qp )
    xp++;               // changes local var xp, not x!
    qp.enque("word");   // adds "word" to the single object referenced by
                        // q and qp
Thus, primitive type instances are always passed by value and class instances are
always passed by reference.
Static methods and state
Normally a method acts on a single object (or instance) of a class. However, it is
possible to define a method that acts on a class itself instead of a particular
instance of the class. These classes are declared static.
The static keyword can also be used on the state variables of the class with a
similar result. The variable becomes a property of the class itself and not any
particular instance.
Static methods can only access the static variables of its class, not the non-static
variables. Here's a very simple example:
public class StaticTest {
  public int ns;         // ns is a normal non-static variable
  public static int s;   // s is a static variable
  public void ns_method() // normal non-static method
     ns = 3;             // can access ns
     s  = 5;             // and s
  public static void s_method() // static method
  {    s = 7;               // can *only* access static s!
Since static methods and instances are properties of a class and not an instance of
a class, they are invoked on the class itself. For example, to call the static method
above, one would type:
Now we are ready to understand our initial Java program:
public class Hello {
  public static void main( String args[] )
    System.out.println("Hello, Java");
System is a name of a class in the Java class library. System.out refers to a static
object in the class that represents the console screen. The println() method is
used to tell System.out to display a string on the console. Note that main() is a
static method.
Object-Oriented Programming and
The preceding section looked at classes from the purely Abstract Data Type view.
The object-oriented paradigm goes further by looking at relationships between
different classes. Often different classes have an IS-A relationship. This type of
relationship exists when one class is a more specialized version of another.
For example, what if one needed a searchable vector class. The Vector class does
not include a method to search for objects inside an instance. However, one could
create a new vector class that performed just like the old Vector class, but directly
supported searching.
The wrong way to do this is to create a new SearchableVector class from scratch
that contains a internal Vector (like how the Queue was implemented). This
would require one to re-specify each of Vector's methods for SearchableVector
(there are many more methods than the one's specified above!).
The right way is to use Java's inheritance mechanism. The SearchableVector
class is an extension of the Vector class. Or, in other words, a SearchableVector
IS-A Vector. A SearchableVector can do anything that a Vector can do, plus
more. Java allows one to simply define a new class that extends the features of an
existing class. The new class automatically has all the state and methods of the
existing class. The syntax is: class subclass extends superclass {
  // new features of subclass
where subclass refers to the new class and superclass refers to the existing class
being extended. All classes in Java are extensions either directly or indirectly from
the Object class. Here is the definition of the SearchableVector class:
public class SearchableVector extends Vector {
  /* search returns the index of the object if found,
   * else -1
  public int search( Object obj )
    for( int i = 0; i < size(); i++ )
      if ( elementAt(i).equals(obj) )
        return i;
    return -1;

In the limit of the for loop, the size() method for a Vector is called. No object is
specified since search() itself is a method and so size() acts on the same object
that search() does. The object a method acts on can be referred to by the this
keyword. The size() call in the for loop could be replaced with this.size() with
the same effect.

Regards :

Er Neha Patidar [ BE ] 
Software Engineer / Webmaster
On Line Assistence :
Gtalk :
Y! Messenger :
Rediff Bol :
KPC Systems & Power Solutions, the most prestigious and progressive trader of reliable andthe batteries for all automobiles, UPS, Inverters, Industrial and other .
Airline Transport Pilot License - information on flight school trainingstudying for an aviation degree, military flying and all the certificates including PPL, CPL ...
NEW FLIGHT SERVICES ISO 9001:2000 CERTIFIED AVIATION ORGANIZATION . Best Pilot training in Philippines with Us
AeroJobMark , Best Pilot Jobs ,Airplane,Aviation, jobs, Airline, Pilot, employment
Everybody has dreamt once of becoming a pilot during their childhood and few are able to make it possible. Becoming a Pilot takes lot of pain and labour, as it is one
AeroSoft Corp, Aviation Company, AeroSoft Aviation SEO Company, information of aerosoft seo company, information of aerosoft aviation seo company


A-1Soft Corp Indore, Asia's Best Travel SEO and KPO Services ...
A-1Soft Corp, Pioneer in Virtual Travels And Tourism Market in Asia, Travels And Tourism Company, A-1Soft Travels And Tourism SEO Company, information of ...


Best GolGappa, Asias Best B2B Portal, Pani Puri, Pani Poori,recipes ...
Asias Best b2b portal, GolGappa, Pani Puri, Pani Poori,recipes,instructions, ingredients, golgapppa.


Wel come To Asiatic Air | Pilot Training Services | Jobs for Freshers ...
Wel come To Asiatic Air | Pilot Training Services, helicopter pilot training in india, free pilot training in india, pilot training in india fees,commercial pilot in india, ...

Wel come To Asiatic Air

Wel come To Asiatic Air | Pilot Training Services | Jobs for ...

About Us

About Us. Asiatic International Aviation Corp. Asiatic ...


Best MCA study Material| MCA books | Best MCA college |Top ...
MCA | BE |BCA| MCA notes | MCA study Material| MCA books | Best MCA college |Top Colleges of India| | Notes |Notes for mca students |MCA Syllabus| MCA ...
Asias Best b2b portal, GolGappa, Pani Puri, Pani Poori,recipes,instructions, ingredients,golgapppa
Mission Vision Passion DBA JHR; B2B B2C OJT Blog FAQ; Search Vender Term Resources; Welcome to AeroSoftSEO. AeroSoft Corp is a very small sized newly establishing ...