পৃষ্ঠাসমূহ

.

Search Your Article

Total Pageviews

Saturday, January 21, 2017

JUnit - Overview

Testing is the process of checking the functionality of an application to ensure it runs as per requirements. Unit testing comes into picture at the developers’ level; it is the testing of single entity (class or method). Unit testing plays a critical role in helping a software company deliver quality products to its customers.
Unit testing can be done in two ways − manual testing and automated testing.

JUnit - Environment Setup

Try it Online Option

We have set up the Java Programming environment online, so that you can compile and execute all the available examples online. It gives you confidence in what you are reading and enables you to verify the programs with different options. Feel free to modify any example and execute it online.

JUnit - Test Framework

JUnit is a Regression Testing Framework used by developers to implement unit testing in Java, and accelerate programming speed and increase the quality of code. JUnit Framework can be easily integrated with either of the following −

JUnit - Basic Usage

Let us now have a basic example to demonstrate the step-by-step process of using JUnit.

Create a Class

Create a java class to be tested, say, MessageUtil.java in C:\>JUNIT_WORKSPACE

JUnit - API

The most important package in JUnit is junit.framework, which contains all the core classes. Some of the important classes are as follows −

JUnit - Writing a Test

Here we will see one complete example of JUnit testing using POJO class, Business logic class, and a test class, which will be run by the test runner.
Create EmployeeDetails.java in C:\>JUNIT_WORKSPACE, which is a POJO class.

JUnit - Using Assertion

Assertion

All the assertions are in the Assert class.
public class Assert extends java.lang.Object
This class provides a set of assertion methods, useful for writing tests. Only failed assertions are recorded. Some of the important methods of Assert class are as follows −

JUnit - Execution Procedure

This chapter explains the execution procedure of methods in JUnit, which defines the order of the methods called. Discussed below is the execution procedure of the JUnit test API methods with example.
Create a java class file named ExecutionProcedureJunit.java in C:\>JUNIT_WORKSPACE to test annotation.

JUnit - Executing Tests

The test cases are executed using JUnitCore class. JUnitCore is a facade for running tests. It supports running JUnit 4 tests, JUnit 3.8.x tests, and mixtures. To run tests from the command line, run java org.junit.runner.JUnitCore <TestClass>. For one-shot test runs, use the static method runClasses(Class[]).
Following is the declaration for org.junit.runner.JUnitCore class:

JUnit - Suite Test

Test suite is used to bundle a few unit test cases and run them together. In JUnit, both @RunWith and @Suite annotations are used to run the suite tests. This chapter takes an example having two test classes, TestJunit1 & TestJunit2, that run together using Test Suite.

JUnit - Ignore Test

Sometimes it so happens that our code is not completely ready while running a test case. As a result, the test case fails. The @Ignore annotation helps in this scenario.

JUnit - Time Test

JUnit provides a handy option of Timeout. If a test case takes more time than the specified number of milliseconds, then JUnit will automatically mark it as failed. The timeout parameter is used along with @Test annotation. Let us see the @Test(timeout) in action.

JUnit - Exceptions Test

JUnit provides an option of tracing the exception handling of code. You can test whether the code throws a desired exception or not. The expected parameter is used along with @Test annotation. Let us see @Test(expected) in action.

JUnit - Parameterized Test

JUnit 4 has introduced a new feature called parameterized tests. Parameterized tests allow a developer to run the same test over and over again using different values. There are five steps that you need to follow to create a parameterized test.

JUnit - Plug with ANT

We will have an example to demonstrate how to run JUnit using ANT. Follow the steps given below.

Step 1: Download Apache Ant

JUnit - Plug with Eclipse

To set up JUnit with eclipse, follow the steps given below.

Step 1: Download JUnit Archive

Download a JUnit jar based on the operating system you have on your system.

JUnit - Extensions

Following are the JUnit extensions −
  • Cactus
  • JWebUnit
  • XMLUnit
  • MockObject

JUnit Questions and Answers

JUnit Questions and Answers has been designed with a special intention of helping students and professionals preparing for various Certification Exams and Job Interviews. This section provides a useful collection of sample Interview Questions and Multiple Choice Questions (MCQs) and their answers with appropriate explanations.

JUnit - Quick Guide

JUnit - Overview

Testing is the process of checking the functionality of an application to ensure it runs as per requirements. Unit testing comes into picture at the developers’ level; it is the testing of single entity (class or method). Unit testing plays a critical role in helping a software company deliver quality products to its customers.
Unit testing can be done in two ways − manual testing and automated testing.

JUnit - Useful Resources

The following resources contain additional information on JUnit. Please use them to get more in-depth knowledge on this topic.

Discuss JUnit

JUnit is a unit testing framework for Java programming language. JUnit has been important in the development of test-driven development, and is one of a family of unit testing frameworks collectively known as xUnit, that originated with JUnit. This tutorial explains the use of JUnit in your project unit testing, while working with Java. After completing this tutorial you will gain sufficient knowledge in using JUnit testing framework from where you can take yourself to next levels.

JSP - Overview

What is JavaServer Pages?

JavaServer Pages (JSP) is a technology for developing web pages that support dynamic content which helps developers insert java code in HTML pages by making use of special JSP tags, most of which start with <% and end with %>.

JSP - Environment Setup

A development environment is where you would develop your JSP programs, test them and finally run them.
This tutorial will guide you to setup your JSP development environment which involves following steps:

JSP - Architecture

The web server needs a JSP engine ie. container to process JSP pages. The JSP container is responsible for intercepting requests for JSP pages. This tutorial makes use of Apache which has built-in JSP container to support JSP pages development.

JSP - Life Cycle

The key to understanding the low-level functionality of JSP is to understand the simple life cycle they follow.
A JSP life cycle can be defined as the entire process from its creation till the destruction which is similar to a servlet life cycle with an additional step which is required to compile a JSP into servlet.
The following are the paths followed by a JSP

JSP - Syntax

This tutorial will give basic idea on simple syntax (ie. elements) involved with JSP development:

The Scriptlet:

A scriptlet can contain any number of JAVA language statements, variable or method declarations, or expressions that are valid in the page scripting language.

JSP - Directives

JSP directives provide directions and instructions to the container, telling it how to handle certain aspects of JSP processing.

JSP - Actions

JSP actions use constructs in XML syntax to control the behavior of the servlet engine. You can dynamically insert a file, reuse JavaBeans components, forward the user to another page, or generate HTML for the Java plugin.

JSP - Implicit Objects

JSP Implicit Objects are the Java objects that the JSP Container makes available to developers in each page and developer can call them directly without being explicitly declared. JSP Implicit Objects are also called pre-defined variables.
JSP supports nine Implicit Objects which are listed below:

JSP - Client Request

When a browser requests for a web page, it sends lot of information to the web server which can not be read directly because this information travel as a part of header of HTTP request. You can check HTTP Protocol for more information on this.

JSP - Server Response

When a Web server responds to a HTTP request to the browser, the response typically consists of a status line, some response headers, a blank line, and the document. A typical response looks like this:
HTTP/1.1 200 OK
Content-Type: text/html

JSP - Http Status Codes

The format of the HTTP request and HTTP response messages are similar and will have following structure:
  • An initial status line + CRLF ( Carriage Return + Line Feed ie. New Line )
  • Zero or more header lines + CRLF
  • A blank line ie. a CRLF

JSP - Form Processing

You must have come across many situations when you need to pass some information from your browser to web server and ultimately to your backend program. The browser uses two methods to pass this information to web server. These methods are GET Method and POST Method.

JSP - Filters

Servlet and JSP Filters are Java classes that can be used in Servlet and JSP Programming for the following purposes:
  • To intercept requests from a client before they access a resource at back end.
  • To manipulate responses from server before they are sent back to the client.

JSP - Cookies Handling

Cookies are text files stored on the client computer and they are kept for various information tracking purpose. JSP transparently supports HTTP cookies using underlying servlet technology.
There are three steps involved in identifying returning users:

JSP - Session Tracking

HTTP is a "stateless" protocol which means each time a client retrieves a Web page, the client opens a separate connection to the Web server and the server automatically does not keep any record of previous client request.
Still there are following three ways to maintain session between web client and web server:

JSP - File Uploading

A JSP can be used with an HTML form tag to allow users to upload files to the server. An uploaded file could be a text file or binary or image file or any document.

JSP - Handling Date

One of the most important advantages of using JSP is that you can use all the methods available in core Java. This tutorial would take you through Java provided Date class which is available in java.util package, this class encapsulates the current date and time.

JSP - Page Redirecting

Page redirection is generally used when a document moves to a new location and we need to send the client to this new location or may be because of load balancing, or for simple randomization.

JSP - Hits Counter

A hit counter tells you about the number of visits on a particular page of your web site. Usually you attach a hit counter with your index.jsp page assuming people first land on your home page.
To implement a hit counter you can make use of Application Implicit object and associated methods getAttribute() and setAttribute().

JSP - Auto Refresh

Consider a webpage which is displaying live game score or stock market status or currency exchange ration. For all such type of pages, you would need to refresh your web page regularly using refresh or reload button with your browser.

JSP - Sending Email

To send an email using a JSP is simple enough but to start with you should have JavaMail API and Java Activation Framework (JAF) installed on your machine.

JSP - Standard Tag Library (JSTL) Tutorial

The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications.

JSP - Database Access

This tutorial assumes you have good understanding on how JDBC application works. Before starting with database access through a JSP, make sure you have proper JDBC environment setup along with a database.
For more detail on how to access database using JDBC and its environment setup you can go through our JDBC Tutorial.

JSP - XML Data

When you send XML data via HTTP, it makes sense to use JSP to handle incoming and outgoing XML documents for example RSS documents. As an XML document is merely a bunch of text, creating one through a JSP is no more difficult than creating an HTML document.

JSP - JavaBeans

A JavaBean is a specially constructed Java class written in the Java and coded according to the JavaBeans API specifications.
Following are the unique characteristics that distinguish a JavaBean from other Java classes:

JSP - Custom Tags

A custom tag is a user-defined JSP language element. When a JSP page containing a custom tag is translated into a servlet, the tag is converted to operations on an object called a tag handler. The Web container then invokes those operations when the JSP page's servlet is executed.

JSP - Expression Language (EL)

JSP Expression Language (EL) makes it possible to easily access application data stored in JavaBeans components. JSP EL allows you to create expressions both (a) arithmetic and (b) logical. Within a JSP EL expression, you can use integers, floating point numbers, strings, the built-in constants true and false for boolean values, and null.

JSP - Exception Handling

When you are writing JSP code, a programmer may leave a coding errors which can occur at any part of the code. You can have following type of errors in your JSP code:

JSP - Debugging

It is always difficult to testing/debugging a JSP and servlets. JSP and Servlets tend to involve a large amount of client/server interaction, making errors likely but hard to reproduce.
Here are a few hints and suggestions that may aid you in your debugging.

JSP - Security

JavaServer Pages and servlets make several mechanisms available to Web developers to secure applications. Resources are protected declaratively by identifying them in the application deployment descriptor and assigning a role to them.

JSP - Internationalization| i18n| l10n

Before we proceed, let me explain three important terms:
  • Internationalization (i18n): This means enabling a web site to provide different versions of content translated into the visitor's language or nationality.

JSP Questions and Answers

JSP Questions and Answers has been designed with a special intention of helping students and professionals preparing for various Certification Exams and Job Interviews. This section provides a useful collection of sample Interview Questions and Multiple Choice Questions (MCQs) and their answers with appropriate explanations.

JSP - Quick Guide

What is JavaServer Pages?

JavaServer Pages (JSP) is a technology for developing web pages that support dynamic content which helps developers insert java code in HTML pages by making use of special JSP tags, most of which start with <% and end with %>.

JSP - Useful Resources

If you want to list down your website, book or any other resource on this page then please contact at webmaster@tutorialspoint.com

Discuss JSP

JavaServer Pages (JSP) is a server-side programming technology that enables the creation of dynamic, platform-independent method for building Web-based applications. JSP have access to the entire family of Java APIs, including the JDBC API to access enterprise databases. This tutorial will teach you how to use Java Server Pages to develop your web applications in simple and easy steps.

JSON - Overview

JSON or JavaScript Object Notation is a lightweight text-based open standard designed for human-readable data interchange. Conventions used by JSON are known to programmers, which include C, C++, Java, Python, Perl, etc.

JSON - Syntax

Let's have a quick look at the basic syntax of JSON. JSON syntax is basically considered as a subset of JavaScript syntax; it includes the following −

JSON - DataTypes

JSON format supports the following data types −
Type Description
Number double- precision floating-point format in JavaScript
String double-quoted Unicode with backslash escaping

JSON - Objects

Creating Simple Objects

JSON objects can be created with JavaScript. Let us see the various ways of creating JSON objects using JavaScript −

JSON - Schema

JSON Schema is a specification for JSON based format for defining the structure of JSON data. It was written under IETF draft which expired in 2011. JSON Schema −

JSON - Comparison with XML

JSON and XML are human readable formats and are language independent. They both have support for creation, reading and decoding in real world situations. We can compare JSON with XML, based on the following factors −

JSON with PHP

This chapter covers how to encode and decode JSON objects using PHP programming language. Let's start with preparing the environment to start our programming with PHP for JSON.

JSON with Perl

This chapter covers how to encode and decode JSON objects using Perl programming language. Let's start with preparing the environment to start our programming with Perl for JSON.

JSON with Python

This chapter covers how to encode and decode JSON objects using Python programming language. Let's start with preparing the environment to start our programming with Python for JSON.

JSON with Ruby

This chapter covers how to encode and decode JSON objects using Ruby programming language. Let's start with preparing the environment to start our programming with Ruby for JSON.

JSON with Java

This chapter covers how to encode and decode JSON objects using Java programming language. Let's start with preparing the environment to start our programming with Java for JSON.

JSON with Ajax

AJAX is Asynchronous JavaScript and XML, which is used on the client side as a group of interrelated web development techniques, in order to create asynchronous web applications. According to the AJAX model, web applications can send and retrieve data from a server asynchronously without interfering with the display and the behavior of the existing page.

JSON - Useful Resources

The following resources contain additional information on JSON. Please use them to get more in-depth knowledge on this.

Discuss JSON

JSON or JavaScript Object Notation is a lightweight text-based open standard designed for human-readable data interchange. The JSON format was originally specified by Douglas Crockford, and is described in RFC 4627. The official Internet media type for JSON is application/json. The JSON filename extension is .json. This tutorial will help you understand JSON and its use within various programming languages such as PHP, PERL, Python, Ruby, Java, etc.

JPA - Introduction

Any enterprise application performs database operations by storing and retrieving vast amounts of data. Despite all the available technologies for storage management, application developers normally struggle to perform database operations efficiently.

JPA - Architecture

Java Persistence API is a source to store business entities as relational entities. It shows how to define a Plain Oriented Java Object (POJO) as an entity and how to manage entities with relations.

JPA - ORM Components

Most contemporary applications use relational database to store data. Recently, many vendors switched to object database to reduce their burden on data maintenance. It means object database or object relational technologies are taking care of storing, retrieving, updating, and maintenance. The core part of this object relational technologies are mapping orm.xml file. As xml does not require compilation, we can easily make changes to multiple data sources with less administration.

Object Relational Mapping

Object Relational Mapping (ORM) briefly tells you about what is ORM and how it works. ORM is a programming ability to covert data from object type to relational type and vice versa.
The main feature of ORM is mapping or binding an object to its data in the database. While mapping we have to consider the data, type of data and its relations with its self-entity or entity in any other table.

Advanced Features

  • Idiomatic persistence : It enables you to write the persistence classes using object oriented classes.
  • High Performance : It has many fetching techniques and hopeful locking techniques.
  • Reliable : It is highly stable and eminent. Used by many industrial programmers.

ORM Architecture

Here follow the ORM architecture.
Object Relational Mapping The above architecture explains how object data is stored into relational database in three phases.

Phase1

The first phase, named as the Object data phase contains POJO classes, service interfaces and classes. It is the main business component layer, which has business logic operations and attributes.
For example let us take an employee database as schema-
  • Employee POJO class contain attributes such as ID, name, salary, and designation. And methods like setter and getter methods of those attributes.
  • Employee DAO/Service classes contains service methods such as create employee, find employee, and delete employee.

Phase 2

The second phase named as mapping or persistence phase which contains JPA provider, mapping file (ORM.xml), JPA Loader, and Object Grid.
  • JPA Provider : The vendor product which contains JPA flavor (javax.persistence). For example Eclipselink, Toplink, Hibernate, etc.
  • Mapping file : The mapping file (ORM.xml) contains mapping configuration between the data in a POJO class and data in a relational database.
  • JPA Loader : The JPA loader works like cache memory, which can load the relational grid data. It works like a copy of database to interact with service classes for POJO data (Attributes of POJO class).
  • Object Grid : The Object grid is a temporary location which can store the copy of relational data, i.e. like a cache memory. All queries against the database is first effected on the data in the object grid. Only after it is committed, it effects the main database.

Phase 3

The third phase is the Relational data phase. It contains the relational data which is logically connected to the business component. As discussed above, only when the business component commit the data, it is stored into the database physically. Until then the modified data is stored in a cache memory as a grid format. Same is the process for obtaining data.
The mechanism of the programmatic interaction of above three phases is called as object relational mapping.

Mapping.xml

The mapping.xml file is to instruct the JPA vendor for mapping the Entity classes with database tables.
Let us take an example of Employee entity which contains four attributes. The POJO class of Employee entity named Employee.java is as follows:
public class Employee {

   private int eid;
   private String ename;
   private double salary;
   private String deg;

   public Employee(int eid, String ename, double salary, String deg) {
      super( );
      this.eid = eid;
      this.ename = ename;
      this.salary = salary;
      this.deg = deg;
   }

   public Employee( ) {
      super();
   }

   public int getEid( ) {
      return eid;
   }
   
   public void setEid(int eid) {
      this.eid = eid;
   }
   
   public String getEname( ) {
      return ename;
   }
   
   public void setEname(String ename) {
      this.ename = ename;
   }

   public double getSalary( ) {
      return salary;
   }
   
   public void setSalary(double salary) {
      this.salary = salary;
   }

   public String getDeg( ) {
      return deg;
   }
   
   public void setDeg(String deg) {
      this.deg = deg;
   }
}
The above code is the Employee entity POJO class. It contain four attributes eid, ename, salary, and deg. Consider these attributes are the table fields in the database and eid is the primary key of this table. Now we have to design hibernate mapping file for it. The mapping file named mapping.xml is as follows:
<? xml version="1.0" encoding="UTF-8" ?>

<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm    
   http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
   version="1.0">
      
   <description> XML Mapping file</description>
      
   <entity class="Employee">        
      <table name="EMPLOYEETABLE"/>
      <attributes>
      
         <id name="eid">
            <generated-value strategy="TABLE"/>
         </id>

         <basic name="ename">
            <column name="EMP_NAME" length="100"/>
         </basic>
         
         <basic name="salary">
         </basic>
         
         <basic name="deg">
         </basic>
         
      </attributes>
   </entity>
   
</entity-mappings>
The above script for mapping the entity class with database table. In this file
  • <entity-mappings> : tag defines the schema definition to allow entity tags into xml file.
  • <description> : tag defines description about application.
  • <entity> : tag defines the entity class which you want to convert into table in a database. Attribute class defines the POJO entity class name.
  • <table> : tag defines the table name. If you want to keep class name as table name then this tag is not necessary.
  • <attributes> : tag defines the attributes (fields in a table).
  • <id> : tag defines the primary key of the table. The <generated-value> tag defines how to assign the primary key value such as Automatic, Manual, or taken from Sequence.
  • <basic> : tag is used for defining remaining attributes for table.
  • <column-name> : tag is used to define user defined table field name.

Annotations

Generally Xml files are used to configure specific component, or mapping two different specifications of components. In our case, we have to maintain xml separately in a framework. That means while writing a mapping xml file we need to compare the POJO class attributes with entity tags in mapping.xml file.
Here is the solution: In the class definition, we can write the configuration part using annotations. The annotations are used for classes, properties, and methods. Annotations starts with ‘@’ symbol. Annotations are declared before the class, property or method is declared. All annotations of JPA are defined in javax.persistence package.
Here follows the list of annotations used in our examples
Annotation Description
@Entity This annotation specifies to declare the class as entity or a table.
@Table This annotation specifies to declare table name.
@Basic This annotation specifies non constraint fields explicitly.
@Embedded This annotation specifies the properties of class or an entity whose value instance of an embeddable class.
@Id This annotation specifies the property, use for identity (primary key of a table) of the class.
@GeneratedValue This annotation specifies, how the identity attribute can be initialized such as Automatic, manual, or value taken from sequence table.
@Transient This annotation specifies the property which in not persistent i.e. the value is never stored into database.
@Column This annotation is used to specify column or attribute for persistence property.
@SequenceGenerator This annotation is used to define the value for the property which is specified in @GeneratedValue annotation. It creates a sequence.
@TableGenerator This annotation is used to specify the value generator for property specified in @GeneratedValue annotation. It creates a table for value generation.
@AccessType This type of annotation is used to set the access type. If you set @AccessType(FIELD) then Field wise access will occur. If you set @AccessType(PROPERTY) then Property wise assess will occur.
@JoinColumn This annotation is used to specify an entity association or entity collection. This is used in many- to-one and one-to-many associations.
@UniqueConstraint This annotation is used to specify the field, unique constraint for primary or secondary table.
@ColumnResult This annotation references the name of a column in the SQL query using select clause.
@ManyToMany This annotation is used to define a many-to-many relationship between the join Tables.
@ManyToOne This annotation is used to define a many-to-one relationship between the join Tables.
@OneToMany This annotation is used to define a one-to-many relationship between the join Tables.
@OneToOne This annotation is used to define a one-to-one relationship between the join Tables.
@NamedQueries This annotation is used for specifying list of named queries.
@NamedQuery This annotation is used for specifying a Query using static name.

Java Bean Standard

Java class, encapsulates the instance values and behaviors into a single unit callled object. Java Bean is a temporary storage and reusable component or an object. It is a serializable class which has default constructor and getter & setter methods to initialize the instance attributes individually.

Bean Conventions

  • Bean contains the default constructor or a file that contains serialized instance. Therefore, a bean can instantiate the bean.
  • The properties of a bean can be segregated into Boolean properties and non-Boolean properties.
  • Non-Boolean property contains getter and setter methods.
  • Boolean property contain setter and is method.
  • Getter method of any property should start with small lettered ‘get’ (java method convention) and continued with a field name that starts with capital letter. E.g. the field name is ‘salary’ therefore the getter method of this field is ‘getSalary ()’.
  • Setter method of any property should start with small lettered ‘set’ (java method convention), continued with a field name that starts with capital letter and the argument value to set to field. E.g. the field name is ‘salary’ therefore the setter method of this field is ‘setSalary (double sal)’.
  • For Boolean property, is method to check if it is true or false. E.g. the Boolean property ‘empty’, the is method of this field is ‘isEmpty ()’.

JPA - Installation

This chapter takes you through the process of setting up JPA on Windows and Linux based systems. JPA can be easily installed and integrated with your current Java environment following a few simple steps without any complex setup procedures. User administration is required while installation.

JPA - Entity Managers

This chapter takes you through simple example with JPA. Let us consider employee management as example. It means the employee management is creating, updating, finding, and deleting an employee. As mentioned above we are using MySQL database for database operations.
The main modules for this example are as follows:

JPA - JPQL

This chapter tells you about JPQL and how it works with persistence units. In this chapter, examples follow the same package hierarchy, which we used in the previous chapter as follows:

JPA - Advanced Mappings

JPA is a library which is released with java specification. Therefore, it supports all object oriented concepts for entity persistence. Till now we are done with the basics of object relational mapping. This chapter takes you through the advanced mappings between objects and relational entities.

JPA - Entity Relationships

This chapter takes you through the relationships between Entities. Generally the relations are more effective between tables in the database. Here the entity classes are treated as relational tables (concept of JPA), therefore the relationships between Entity classes are as follows:

JPA - Criteria API

The Criteria API is a predefined API used to define queries for entities. It is the alternative way of defining a JPQL query. These queries are type-safe, and portable and easy to modify by changing the syntax. Similar to JPQL it follows abstract schema (easy to edit schema) and embedded objects. The metadata API is mingled with criteria API to model persistent entity for criteria queries.

Java DIP - Useful Resources

The following resources contain additional information on JPA. Please use them to get more in-depth knowledge on this.

Discuss JPA

Java Persistence API is a collection of classes and methods to persistently store the vast amounts of data into a database which is provided by the Oracle Corporation. This tutorial provides you the basic understanding of Persistence (storing the copy of database object into temporary memory), and we will learn the understanding of JAVA Persistence API (JPA).

JOGL - Overview

This chapter introduces OpenGL, its functions, the OpenGL bindings in java (GL4java, LWJGL, JOGL), and the advantages of JOGL over other OpenGL bindings.

JOGL - Installation

This chapter covers setting up of the environment to use JOGL on your system using different Integrated Development Environments (IDEs).

JOGL - API for Basic Template

Using JOGL programming, it is possible to draw various graphical shapes such as straight lines, triangles, 3D shapes including special effects such as rotation, lighting, colors, etc. To draw objects in JOGL first of all we have to construct a basic JOGL frame. Below given are the classes required to construct a basic frame.

JOGL - Canvas with AWT

This chapter explains you how to draw a JOGL basic frame using Canvas with AWT frame. In here we will construct a AWT Frame and add the canvas object to the AWT frame using the add() method of the frame class.

JOGL - Canvas with Swing

This chapter explains you how to draw a JOGL basic frame using Canvas, and JFrame class of javax.swing package. In here we will instantiate a JFrame and add the canvas object to the instance of JFrame using the add() method.

JOGL - GLJPanel Class

This chapter explains you how to draw a JOGL basic frame using GLJpanel class. It is a lightweight Swing component which provides OpenGL rendering support. It is provided for compatibility with Swing. In here we will instantiate a JFrame and add the GLJpanel object to the instance of JFrame using the add() method.

JOGL - Drawing Basics

OpenGL API has provided primitive methods for drawing basic graphical elements such as point, vertex, line etc. Using these methods, you can develop shapes such as triangle, polygon and circle. In both, 2D and 3D dimensions. This chapter teaches you how to draw a basic line using JOGL in a Java program.

JOGL - Drawing with GL Lines

In the Previous chapter we have learned how draw a basic line using JOGL. We draw lines by passing a predefined field, Gl_lines to glBegin() method.
This chapter provides examples to draw shapes like triangle, rhombus and a house, using glBegin() method and GL_Lines.

JOGL - Pre Defined Shapes

In the Previous chapters we have learned how draw a shapes such as line, triangle, rhombus using JOGL. We draw lines by passing a predefined field, Gl_lines to glBegin() method.
Other than GL_LINES, the glBegin() method accepts eight more parameters. You can use them to draw different shapes.

JOGL - Transformation

OpenGL provides more features such as applying colors to an object, scaling, lighting, rotating an object, etc. This chapter describes some of the transformations on objects using JOGL.

JOGL - Coloring

This chapter teaches you how to apply colours to the objects using JOGL. To apply colour to an object, use the method glColor() of GL2. Below given is the syntax for using glColor method.

JOGL - Scaling

This chapter teaches you how to scale an object ie., increase or decrease the size of an object using JOGL.
Scaling an object is done by using the glScalef(float x, float y, float z) method of GLMatrixFunc interface. This method accepts three floating point parameters, using which we specify the scale factors along the x, y, and z axes respectively.

JOGL - Rotation

In this chapter we explained you how to rotate an object using JOGL. Rotation of objects can be done along any of the three axes, using the glRotatef(float angle, float x, float y, float z) method of GLMatrixFunc interface. You need to pass an angle of rotation and x, y, z axes as parameters to this method.
The following steps guide you to rotate an object successfully −

JOGL - Lighting

This chapter explains you how to apply lighting effect to an object using JOGL.
To set lighting, initially enable lighting using the glEnable() method. Then apply lighting for the objects, using the glLightfv(int light, int pname, float[] params, int params_offset) method of GLLightingFunc interface. This method takes four parameters.

JOGL - 3D Basics

In previous chapters we have seen how to create 2d objects, apply effects to it, and transform the object. This chapter teaches you how to draw a line with 3rd dimension, and some shapes.

JOGL - 3D Triangle

In previous chapter we have seen how to draw 3d shapes, this chapter teaches you how to draw 3d triangle and rotate it.
Below given is the program to draw a 3d triangle an rotate it.

JOGL - 3D Cube

In the previous chapters we have seen how to draw 3d triangle and rotate it. Now in this chapter you can learn how to a 3d cube, how to rotate it, how to attach an image on it. In the same way, This chapter provides examples to draw a 3D cube and apply colours to it and attach image to it.

JOGL - Appendix

GPU − Graphical processing unit, it is a special electronic device that accelerates the rendering of images.
JNI − Java Native Interface. Using which, java access native methods.

JOGL - Useful Resources

The following resources contain additional information on JOGL. Please use them to get more in-depth knowledge on this topic.

Discuss JOGL

Java binding for OpenGL (JOGL) is an open source library for binding OpenGL graphics in Java. This tutorial provides a basic understanding of JOGL library and its features. It also explains how to develop 2D and 3D graphics applications using JOGL.

Friday, January 20, 2017

jMeter - Overview

Before going into the details of JMeter, let us first understand a few jargons associated with the testing of any application.

jMeter - Environment

JMeter is a framework for Java, so the very first requirement is to have JDK installed in your machine.

System Requirement

jMeter - Build Test Plan

What is a Test Plan?

A Test Plan can be viewed as a container for running tests. It defines what to test and how to go about it. A complete test plan consists of one or more elements such as thread groups, logic controllers, sample-generating controllers, listeners, timers, assertions, and configuration elements. A test plan must have at least one thread group.

jMeter - Test Plan Elements

A JMeter Test Plan comprises of test elements discussed below. A Test Plan comprises of at least one Thread Group. Within each Thread Group, we may place a combination of one or more of other elements − Sampler, Logic Controller, Configuration Element, Listener, and Timer. Each Sampler can be preceded by one or more Pre-processor element, followed by Post-processor element, and/or Assertion element. Let us see each of these elements in detail −

jMeter - Web Test Plan

Let us build a simple test plan which tests a web page. We write a test plan in Apache JMeter so that we can test the performance of the web page shown by the URL − http://www.tutorialspoint.com/.

jMeter - Database Test Plan

In this chapter, we will see how to create a simple test plan to test the database server. For our test purpose we use the MYSQL database server. You can use any other database for testing. For installation and table creation in MYSQL please refer MYSQL Tutorial.

jMeter - FTP Test Plan

In this chapter, we will see how to test a FTP site using JMeter. Let us create a Test Plan to test the FTP site.

Rename Test Plan

jMeter - Webservice Test Plan

In this chapter, we will learn how to create a Test Plan to test a WebService. For our test purpose, we have created a simple webservice project and deployed it on the Tomcat server locally.

jMeter - JMS Test Plan

In this chapter, we will learn how to write a simple test plan to test Java Messaging Service (JMS). JMS supports two types of messaging −

jMeter - Monitor Test Plan

In this chapter, we will discuss how to create a Test Plan using JMeter to monitor webservers. The uses of monitor tests are as follows −

jMeter - Listeners

Listeners provide access to the information JMeter gathers about the test cases while JMeter runs. The results or information gathered by listeners can be shown in the form of −

jMeter - Functions

JMeter Functions and User Variables

JMeter functions are special values that can populate fields of any Sampler or other element in a test tree.
  • A function call looks like this −

jMeter - Regular Expressions

Regular expressions are used to search and manipulate text, based on patterns. JMeter interprets forms of regular expressions or patterns being used throughout a JMeter test plan, by including the pattern matching software Apache Jakarta ORO.

jMeter - Best Practices

JMeter has some limitations especially when it is run in a distributed environment. Following these guidelines will assist in creating a real and continuous load −

jMeter - Useful Resources

The following resources contain additional information on JMeter. Please use them to get more in-depth knowledge on this topic.

Discuss jMeter

jMeter is an open source testing software. It is 100% pure Java application for load and performance testing. jMeter is designed to cover various categories of tests such as load testing, functional testing, performance testing, regression testing, etc., and it requires JDK 5 or higher. This tutorial provides an in-depth coverage of jMeter framework including its test plans, listeners, functions, and regular expressions.

JFreeChart - Overview

A chart is a graphical representation of information. There are various tools available, which can be used to create different types of charts.
This tutorial helps you to understand what exactly the JfreeChart is, why is it required and the various ways to create different types of charts within a Java based application or independently.

JFreeChart Installation

This chapter takes you through the process of setting up JFreeChart on Windows and Linux. User administration is needed while installing the JFreeChart. The JFreeChart is famous for its efficient chart creation, and user-friendly installation setup.

JFreeChart Architecture

This chapter explains basic class level and application level architectures of JFreeChart to give you an idea about how JFreeChart interacts with different classes and how it fits in your Java based application.

JFreeChart Referenced APIs

In this chapter, we will discuss about some important packages, classes and methods from JFreeChart library. These packages, classes and methods are the most frequently used while creating a variety of charts using JFreeChart library.

JFreeChart - Pie Chart

In a pie chart, the arc length of each sector is proportional to the quantity it represents. This chapter demonstrates how we can use JFreeChart to create Pie Chart from a given set of business data.

JFreeChart - Bar Chart

This chapter demonstrates how we can use JFreeChart to create Bar Chart from a given set of business data.
A bar chart uses different orientation (horizontal or vertical) bars to show comparisons in various categories. One axis (domain axis) of the chart shows the specific domain being compared, and the other axis (range axis) represents discrete values.

JFreeChart - Line Chart

A line chart or line graph displays information as a series of data points (markers) connected by straight line segments. Line Chart shows how the data changes at equal time frequency. This chapter demonstrates how we can use JFreeChart to create Line Chart from a given set of business data.

JFreeChart - XY Chart

The xy chart (scatter) is based on one data series consisting of a list of x and y values. Each value pair (x,y) is a point in a coordinate system. Here, one value determines the horizontal (X) position, and the other determines the vertical (Y) position. This chapter demonstrates how we can use JFreeChart to create XY Chart from a given set of business data.

JFreeChart - 3D Pie/Bar Chart

The 3D charts are the ones, which appear in a three-dimensional format. You can use these charts to provide better display and clear information. A 3D Pie chart is same as the pie chart additionally with a nice 3D effect. A 3D effect can achieved by adding a little extra code which will take care of creating 3D effect in a pie chart.

JFreeChart - Bubble Chart

This chapter demonstrates how you can use JFreeChart to create Bubble Chart from a given set of business data. A bubble chart displays information in three-dimensional way. A bubble is plotted at the place where (x, y) coordinate intersect. The size of the bubble is considered as range or quantity of X and Y axis.

JFreeChart - TimeSeries Chart

A time series chart displays sequence of data points, which varies at equal intervals of time. This chapter demonstrates how we can use JFreeChart to create Time Series Chart from a given set of business data.

JFreeChart - File Interface

So far we studied how to create various types of charts using JFreeChart APIs using static data. But in production environment, data is provided in the form of text file with a predefined format, or it comes directly from the database.

JFreeChart - Database Interface

This chapter explains how you can read simple data from a database table and then use JFreeChart to create a chart of your choice.

JFreeChart - Useful Resources

The following resources contain additional information on JFreeChart. Please use them to get more in-depth knowledge on this topic.

Useful Links on JFreeChart

Useful Books on Java

  • Java, A Beginner's Guide
  • Effective Java
  • Sams Teach Yourself Java in 24 Hours
  • Beginning Programming with Java For Dummies
  • Building Java Programs
  • Introduction to Java Programming
To enlist your site on this page, please drop an email to contact@tutorialspoint.com

Discuss JFreeChart

This tutorial describes various ways to incorporate JFreeChart in Java based standalone and web based applications. It will give you a quick start with JFreeChart and make you comfortable with JFreeChart programming with Java applications.

JDBC - Introduction

What is JDBC?

JDBC stands for Java Database Connectivity, which is a standard Java API for database-independent connectivity between the Java programming language and a wide range of databases.
The JDBC library includes APIs for each of the tasks mentioned below that are commonly associated with database usage.

JDBC - SQL Syntax

Structured Query Language (SQL) is a standardized language that allows you to perform operations on a database, such as creating entries, reading content, updating content, and deleting entries.
SQL is supported by almost any database you will likely use, and it allows you to write database code independently of the underlying database.

JDBC - Environment Setup

To start developing with JDBC, you should setup your JDBC environment by following the steps shown below. We assume that you are working on a Windows platform.

JDBC - Sample, Example Code

This chapter provides an example of how to create a simple JDBC application. This will show you how to open a database connection, execute a SQL query, and display the results.
All the steps mentioned in this template example, would be explained in subsequent chapters of this tutorial.

JDBC - Driver Types

What is JDBC Driver?

JDBC drivers implement the defined interfaces in the JDBC API, for interacting with your database server.
For example, using JDBC drivers enable you to open database connections and to interact with it by sending SQL or database commands then receiving results with Java.

JDBC - Database Connections

After you've installed the appropriate driver, it is time to establish a database connection using JDBC.
The programming involved to establish a JDBC connection is fairly simple. Here are these simple four steps

JDBC - Statements, PreparedStatement and CallableStatement

Once a connection is obtained we can interact with the database. The JDBC Statement, CallableStatement, and PreparedStatement interfaces define the methods and properties that enable you to send SQL or PL/SQL commands and receive data from your database.

JDBC - Result Sets

The SQL statements that read data from a database query, return the data in a result set. The SELECT statement is the standard way to select rows from a database and view them in a result set. The java.sql.ResultSet interface represents the result set of a database query.

JDBC - Data Types

The JDBC driver converts the Java data type to the appropriate JDBC type, before sending it to the database. It uses a default mapping for most data types. For example, a Java int is converted to an SQL INTEGER. Default mappings were created to provide consistency between drivers.

JDBC - Transactions

If your JDBC Connection is in auto-commit mode, which it is by default, then every SQL statement is committed to the database upon its completion.
That may be fine for simple applications, but there are three reasons why you may want to turn off the auto-commit and manage your own transactions −

JDBC - Exceptions Handling

Exception handling allows you to handle exceptional conditions such as program-defined errors in a controlled fashion.

JDBC - Batch Processing

Batch Processing allows you to group related SQL statements into a batch and submit them with one call to the database.
When you send several SQL statements to the database at once, you reduce the amount of communication overhead, thereby improving performance.

JDBC - Stored Procedure

We have learnt how to use Stored Procedures in JDBC while discussing the JDBC - Statements chapter. This chapter is similar to that section, but it would give you additional information about JDBC SQL escape syntax.

JDBC - Streaming ASCII and Binary Data

A PreparedStatement object has the ability to use input and output streams to supply parameter data. This enables you to place entire files into database columns that can hold large values, such as CLOB and BLOB data types.

JDBC - Create Database Example

This tutorial provides an example on how to create a Database using JDBC application. Before executing the following example, make sure you have the following in place −

JDBC - Select Database Example

This chapter provides an example on how to select a Database using JDBC application. Before executing the following example, make sure you have the following in place −

JDBC - Drop Database Example

This chapter provides an example on how to drop an existing Database using JDBC application. Before executing the following example, make sure you have the following in place −

JDBC - Create Tables Example

This chapter provides an example on how to create a table using JDBC application. Before executing the following example, make sure you have the following in place −

JDBC - Drop Tables Example

This chapter provides an example on how to delete a table using JDBC application. Before executing the following example, make sure you have the following in place −

JDBC - Insert Records Example

This chapter provides an example on how to insert records in a table using JDBC application. Before executing following example, make sure you have the following in place −

JDBC - Select Records Example

This chapter provides an example on how to select/ fetch records from a table using JDBC application. Before executing the following example, make sure you have the following in place −

JDBC - Update Records Example

This chapter provides an example on how to update records in a table using JDBC application. Before executing the following example, make sure you have the following in place −

JDBC - Delete Records Example

This chapter provides an example on how to delete records from a table using JDBC application. Before executing following example, make sure you have the following in place −

JDBC - WHERE Clause Example

This chapter provides an example on how to select records from a table using JDBC application. This would add additional conditions using WHERE clause while selecting records from the table. Before executing the following example, make sure you have the following in place −

JDBC - Like Clause Example

This chapter provides an example on how to select records from a table using JDBC application. This would add additional conditions using LIKE clause while selecting records from the table. Before executing the following example, make sure you have the following in place −

JDBC - Sorting Data Example

This chapter provides an example on how to sort records from a table using JDBC application. This would use asc and desc keywords to sort records in ascending or descending order. Before executing the following example, make sure you have the following in place −

JDBC Questions and Answers

JDBC Questions and Answers has been designed with a special intention of helping students and professionals preparing for various Certification Exams and Job Interviews. This section provides a useful collection of sample Interview Questions and Multiple Choice Questions (MCQs) and their answers with appropriate explanations.

JDBC - Useful Resources

The following resources contain additional information on JDBC Please use them to get more in-depth knowledge on this topic.

Discuss JDBC

JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database. JDBC works with Java on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.

JDB - Introduction

Debugging is a technical procedure to find and remove bugs or defects in a program and get expected results. Debugging includes testing and monitoring. It is very complex when the subunits of a program are tightly coupled.

JDB - Installation

This chapter explains how to install JDB on Windows and Linux based systems. JDB is a part of JDK. Therefore, JDK installation is enough for using JDB in command prompt.

JDB - Syntax

This chapter explains the syntax of JDB command. The syntax contains four sections listed as follows:
  • JDB
  • option
  • class
  • arguments

JDB - Options

This chapter describes the important options available in JDB that are submitted as arguments with the jdb command.

JDB - Session

This chapter describes how to start a JDB session in different ways. JDB launch is the frequently used technique to start a JDB session.
There are two different ways to start a JDB session:

JDB - Basic Commands

This chapter takes you through the basic commands of JDB. After launching a session, these commands are used for debugging a program.
The following is the list of commands used for debugging.

JDB - Breakpoints

This chapter explains the concept of breakpoints and how to set breakpoints in a program. A breakpoint introduces an explicit stop or pause in the execution of a program at a particular line of code while debugging. It is useful to acquire knowledge about variables in the program in its execution.

JDB - Stepping

This chapter explains how to use the concept of Stepping in debugging a program. Stepping is the debugger feature that lets you execute the code by stepping through line by line. Using this, you can examine each line of the code to ensure they are behaving as intended.

JDB - Exception

This chapter explains how to handle the exception class using JDB. Generally, whenever a program raises an exception without a catch statement, then the VM prints the exception line, the cause of the exception, and exits.

JDB - In Eclipse

This chapter explains how to use JDB in Eclipse. Before proceeding further, you need to install Eclipse Indigo. Follow the steps given below to install Eclipse Indigo on your system.

Step 1: Download and Install Eclipse

You can download Eclipse from the following link: http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/indigosr2

Step 2: Create a New Project and a New Class

  • Create a new Java project by following the options File-> New -> Java project.
  • Name it as “sampledebug”.
  • Create a new class by right clicking on the samplebebug project.
  • Select options ->new -> class
  • Name it as “Add.java”

Add.java

public class Add
{
   public int addition( int x, int y)
   {
      int z = x + y;
      return z;
   }
   public static void main( String ar[ ] )
   {
      int a = 5, b = 6;
      Add ob = new Add();
      
      int c = ob.addition(a,b);
      System.out.println("Add: " + c);
   }
}

Step 3: Open the Debug Perspective

Follow the instructions given below to open the debug perspective.
On the Eclipse IDE, go to Window -> Open perspective -> Debug. Now you get the debug perspective for the program Add.java. You get to see the following window.
Debug Perspective

Sections in Debug Perspective

The sections in the Debug perspective are as follows:

Coding Section

Java code is displayed in this section. It is the code you want to debug, that is, Add.java. Here we can add a breakpoint on a line by double clicking in front of the line. You find the blue bubble with an arrow symbol to point out the breakpoint of that line. See the following screenshot; you can find the selected area with a red circle pointed as “1”.
  1. Double click here. You can set the breakpoint for this line.
Code Section

Breakpoint Section

This section defines the list of breakpoints that are set to the program code. Here we can add, delete, find, and manage the breakpoints. The following screenshot shows the breakpoint section.
Breakpoint Section Observe the following options in the given screenshot:
  1. Using the check box in the left, we can select or deselect a breakpoint. Here, we use one breakpoint, i.e., Add class-main() method.
  2. The single cross icon “X” is used to delete the selected breakpoint.
  3. The double cross icon “XX” is used to delete all the breakpoints in your code.
  4. The arrow pointer is used to point to the code where the selected breakpoint is applied.
The remaining functionalities in the breakpoint section are as follows:
  • Hitcount : It shows how many times the control hits this breakpoint. It is used for recursive logic.
  • Suspend thread : We can suspend the current thread by selecting it.
  • Suspend VM : We can suspend the VM by selecting it.

Debug Section

This section is used for the process of debugging. It contains options that are used in debugging.
Start debugging : Follow the instructions given below to start debugging.
Right click on the code -> click Debug as -> click 1 Java application.
The process of debugging starts as shown in the following screenshot. It contains some selected options, highlighted using numeric digits.
  1. We apply a breakpoint on the Add class main() method. When we start debugging, the controller gets stuck at the first line of the main() method.
  2. It is used to Resume the debugging process and skip the current breakpoint. It works similar to the cont command in the JDB command line.
  3. It is used to stop the debugging process.
  4. It works similar to the step in process in the JDB command line. It is used for moving the control to the next line, i.e., point “1” moves to the next line.
  5. It works similar to the step over process in the JDB command line.
  6. It is used to see on which line the breakpoint is applied.
Debug Section Follow the given steps and sections to debug your code in eclipse IDE. By default, every IDE contains this debugging process.

JDB - Useful Resources

The following resources contain additional information on JDB. Please use them to get more in-depth knowledge on this topic.

Discuss JDB

The Java Debugger, commonly known as jdb, is a useful tool to detect bugs in Java programs. This is a brief tutorial that provides a basic overview of how to use this tool in practice. In addition, the tutorial also covers how to debug a program through stepping, breakpoints, and managing exceptions.

jBPM5 - Overview

JBPM stands for "Java Business Process Management". It is a JBoss product which is an open source framework. Before moving further, let us first define a business process.

jBPM5 - Eclipse Plugin

The following are the Prerequisites to install jBPM Plugin −
  • Java 1.5 (or higher) SE JDK
  • Eclipse 4.2 or any version and the jBPM plugin

jBPM5 - Hello World!

Here in this chapter, we will write our first program "Hello World" using jBPM. Follow the steps given below −
Go to File → New → Drools Project −

jBPM5 - Components

BPMS core is the heart of the BPM. The following illustration depicts the BPMS core and its components.

jBPM5 - Workflow Components

The following screenshot show the various workflow components available in jBPM 5. Using these components, you can create a workflow to orchestrate your process.

jBPM5 - Draw & Validate a Workflow

To draw a workflow, you can use any of the components available in the palette as described in above article. All the workflow will have one start but it can have multiple end.
With the help of screenshots, I will depict you how to create a workflow.

jBPM5 - Example

We will take an example in this chapter to explain how to put jBPM into practice. The task at hand is to use jBPM to decide whether a passenger will board a flight or a train, depending upon his income.

jBPM5 - Useful Resources

The following resources contain additional information on jBPM5. Please use them to get more in-depth knowledge on this.

Discuss jBPM5

Organizations throughout the world have been searching for a structured approach of designing their actions or transactions which can be transformed by implementing them using automated solutions. jBPM is one such tool that helps business automation needs of an organization. This tutorial provides an overview of how to use jBPM 5 in practice.

JavaMail API - Overview

The JavaMail API provides a platform-independent and protocol-independent framework to build mail and messaging applications. The JavaMail API provides a set of abstract classes defining objects that comprise a mail system. It is an optional package (standard extension) for reading, composing, and sending electronic messages.

JavaMail API - Environment Setup

To send an e-mail using your Java Application is simple enough but to start with you should have JavaMail API and Java Activation Framework (JAF) installed on your machine.

JavaMail API - Core Classes

The JavaMail API consists of some interfaces and classes used to send, read, and delete e-mail messages. Though there are many packages in the JavaMail API, will cover the main two packages that are used in Java Mail API frequently: javax.mail and javax.mail.internet package. These packages contain all the JavaMail core classes. They are:

JavaMail API - Sending Emails

Now that we have a fair idea about JavaMail API and its core classes, let us now write a simple programs which will send simple email, email with attachments, email with HTML content and email with inline images.
Basic steps followed in all the above scenarios are as below:

JavaMail API - Checking Emails

There are two aspects to which needs to understood before proceeding with this chapter. They are Check and Fetch.
  • Checking an email in JavaMail is a process where we open the respective folder in the mailbox and get each message. Here we only check the header of each message i.e the From, To, subject. Content is not read.

JavaMail API - Fetching Emails

In the previous chapter we learnt how to check emails. Now let us see how to fetch each email and read its content. Let us write a Java class FetchingEmail which will read following types of emails:

JavaMail API - Authentication

In the previous chapters Checking Emails and Fetching Emails, we passed authorization credentials (user ad password) along with host, when connecting to store of your mailbox. Instead we can configure the Properties to have the host, and tell the Session about your custom Authenticator instance. This is shown in the example below:

JavaMail API - Replying Emails

In this chapter we will see how to reply to an email using JavaMail API. Basic steps followed in the program below are:
  • Get the Session object with POP and SMPT server details in the properties. We would need POP details to retrieve messages and SMPT details to send messages.

JavaMail API - Forwarding Emails

In this chapter we will see how to forward an email using JavaMail API. Basic steps followed in the program below are:
  • Get the Session object with POP and SMPT server details in the properties. We would need POP details to retrieve messages and SMPT details to send messages.

JavaMail API - Deleting Emails

In this chapter we will see how to delete an email using JavaMail API. Deleting messages involves working with the Flags associated with the messages. There are different flags for different states, some system-defined and some user-defined. The predefined flags are defined in the inner class Flags.Flag and are listed below:

JavaMail API - Gmail SMPT Server

In all previous chapters we used JangoSMPT server to send emails. In this chapter we will learn about SMPT server provided by Gmail. Gmail (among others) offers use of their public SMTP server free of charge.

JavaMail API - Folder Management

So far, we’ve worked in our previous chapters mostly with the INBOX folder. This is the default folder in which most mail resides. Some systems might call it as INBOX and some other might call it by some other name. But,you can always access it from the JavaMail API using the name INBOX.

JavaMail API - Quota Management

A quota in JavaMail is a limited or fixed number or amount of messages in a email store. Each Mail service request counts toward the JavaMail API Calls quota. An email service can apply following quota criterion:

JavaMail API - Bounced Messages

A message can be bounced for several reasons. This problem is discussed in depth at rfc1211. Only a server can determine the existence of a particular mailbox or user name. When the server detects an error, it will return a message indicating the reason for the failure to the sender of the original message.

JavaMail API - SMTP Servers

SMTP is an acronym for Simple Mail Transfer Protocol. It is an Internet standard for electronic mail (e-mail) transmission across Internet Protocol (IP) networks. SMTP uses TCP port 25. SMTP connections secured by SSL are known by the shorthand SMTPS, though SMTPS is not a protocol in its own right.

JavaMail API - IMAP Servers

IMAP is Acronym for Internet Message Access Protocol. It is an Application Layer Internet protocol that allows an e-mail client to access e-mail on a remote mail server. An IMAP server typically listens on well-known port 143. IMAP over SSL (IMAPS) is assigned to port number 993.

JavaMail API - POP3 Servers

Post Office Protocol (POP) is an application-layer Internet standard protocol used by local e-mail clients to retrieve e-mail from a remote server over a TCP/IP connection. POP supports simple download-and-delete requirements for access to remote mailboxes. A POP3 server listens on well-known port 110.

JavaMail API - Useful Resources

If you want to list down your website, book or any other resource on this page, then please contact at webmaster@tutorialspoint.com

Useful Websites on JavaMail API

Discuss JavaMail API

The JavaMail API provides a platform-independent and protocol-independent framework to build mail and messaging applications. The JavaMail API provides a set of abstract classes defining objects that comprise a mail system. It is an optional package (standard extension) for reading, composing, and sending electronic messages.

Thursday, January 19, 2017

JavaFX - Overview

Rich Internet Applications are those web applications which provide similar features and experience as that of desktop applications. They offer a better visual experience when compared to the normal web applications to the users. These applications are delivered as browser plug-ins or as a virtual machine and are used to transform traditional static applications into more enhanced, fluid, animated and engaging applications.

JavaFX - Environment

From Java8 onwards, the JDK (Java Development Kit) includes JavaFX library in it. Therefore, to run JavaFX applications, you simply need to install Java8 or later version in your system.
In addition to it, IDE’s like Eclipse and NetBeans provide support for JavaFX. This chapter teaches you how to set the environment to run JavaFX Applications in various ways.

JavaFX - Architecture

JavaFX provides a complete API with a rich set of classes and interfaces to build GUI applications with rich graphics. The important packages of this API are −

JavaFX - Application

In this chapter, we will discuss the structure of a JavaFX application in detail and also learn to create a JavaFX application with an example.

JavaFX - 2D Shapes

In the previous chapter, we have seen the basic application of JavaFX, where we learnt how to create an empty window and how to draw a line on an XY plane of JavaFX. In addition to the line, we can also draw several other 2D shapes.

JavaFX - Text

Just like various shapes, you can also create a text node in JavaFX. The text node is represented by the class named Text, which belongs to the package javafx.scene.text.
This class contains several properties to create text in JavaFX and modify its appearance. This class also inherits the Shape class which belongs to the package javafx.scene.shape.

JavaFX - Effects

An effect is any action that enhances the appearance of the graphics. In JavaFX, an effect is an algorithm that is applied on nodes to enhance their appearance visually. The effect property of the Node class is used to specify the effect.

JavaFX - Transformations

Transformation means changing some graphics into something else by applying rules. We can have various types of transformations such as Translation, Scaling Up or Down, Rotation, Shearing, etc.
Using JavaFX, you can apply transformations on nodes such as rotation, scaling and translation. All these transformations are represented by various classes and these belong to the package

JavaFX - Animations

In general, animating an object implies creating illusion of its motion by rapid display. In JavaFX, a node can be animated by changing its property over time. JavaFX provides a package named javafx.animation. This package contains classes that are used to animate the nodes.

JavaFX - Colors

To apply colors to an application, JavaFX provides various classes in the package javafx.scene.paint package. This package contains an abstract class named Paint and it is the base class of all the classes that are used to apply colors.

JavaFX - Images

You can load and modify images using the classes provided by JavaFX in the package javafx.scene.image. JavaFX supports the image formats like Bmp, Gif, Jpeg, Png.
This chapter teaches you how to load images in to JavaFX, how to project an image in multiple views and how to alter the pixels of an image.