Java Programming Tutorials

Introduction
Have you ever searched for files and folders in Windows operating system? Generally most of the users try to search various .doc files, .pdf files etc. We generally search by giving *.doc or *.pdf in the text box of the search window of the windows OS. Of course windows OS provides...

Introduction
The 'main()' method in Java is referred to the thread that is running, whenever a Java program runs. It calls the main thread because it is the first thread that starts running when a program begins. Other threads can be spawned from this main thread. The main thread must be the...

There are four types of JSP tags, which are important and often required.
1. Directives
These types of tags are used primarily to import packages. Altenatively you can also use these tags to define error handling pages and for session information of JSP page.
<%@page language="java" %>
...

Using Regular Expressions in Java
JDK versions 1.4.0 and later have comprehensive support for regular expressions through the standard java.util.regex package. Because Java lacked a regex package for so long, there are also many 3rd party regex packages available for Java. I will only discuss...

LDAP - The Lightweight Directory Access Protocol
This directory access protocol which can either act as a gateway to other service or provide service itself. LDAP follows standardized way of managing directory information solutions of X.500.
The Lightweight Directory Access Protocol, better...

People generally have doubt that when we use Hibernate we simply use configuration to create SessionFactory(). Using that we create session for JDBC connection. But all these SessionFactory and Session class are interfaces. But there is no class available with this name which implements methods of...

Struts is a free open-source framework for creating Java web applications.
Web applications differ from conventional websites in that web applications can create a dynamic response. Many websites deliver only static pages. A web application can interact with databases and business logic engines...

A thread can be created in Java programs in two ways – by extending Thread class and by implementing Runnable interface. In case, where the class extends a Tread class, it must override run() method of the Thread class. The program may override the other methods also. If the program uses Runnable...

Introduction
JavaServer Faces solves many of the historical problems of Java Web development by providing a clean implementation of the Model-View-Controller design pattern while providing a productive, component-centric development without sacrificing development power and flexibility....

Introduction
Java environment has been built around the multithreading model. In fact all Java class libraries have been designed keeping multithreading in mind. If a thread goes off to sleep for some time, the rest of the program does not get affected by this. Similarly, an animation loop can...

The exception handling mechanism is a cleaner way to impose check upon the conditions which may lead to errors. But you should not be carried away by it and start using exception handling anywhere and everywhere you want. Exceptions must be carefully planned and implemented. The following cases...

Java defines several built-in classes for exception handling. All these classes are a part of the java.lang package which is automatically imported. That is why, while throwing an exception you did not specifically include any package for exception classes.
Apart from the built-in exception...

Just like the multiple catch blocks, we can also have multiple try blocks. These try blocks may be written independently or we can nest the try blocks within each other, i.e., keep one try-catch block within another try-block. The program structure for nested try statement is:
try
{
//...

Introduction
The code bound by the try block need not always throw a single exception. If in a try block multiple and varied exceptions are thrown, then you can place multiple catch blocks for the same try block in order to handle all those exceptions. When an exception is thrown it traverses...

The finally clause is written with the try-catch statement. It is guarenteed to be executed after a catch block or before the method quits.
try
{
// statements
}
catch (<exception> obj)
{
// statements
}

You have seen that an exception is thrown either implicitly in the try block and there is a catch block ready to handle it. But, there are methods, which throw the exception, but do not catch it within the method body. In this case the method which is throwing the exception must use a throws clause...

Before you can catch an exception, some code somewhere must throw one. Any code can throw an exception: your code, code from a package written by someone else such as the packages that come with the Java platform, or the Java runtime environment. Regardless of what throws the exception, it's always...

Introduction
The code which is expected to generate the exception must be enclosed in the try and catch block. The very basic form of the exception-handling block is as following:
try
{
//code which is expected to generate the exception
}
catch (<ExceptionTypeClass> object)
{...