Java J2EE Portal
Enterprise Java Station
J2EE curve
Java News / Articles
Java News / Articles
Implementing Document Management using the Alfresco Enterprise CMS
Complementing Unit Test with Dependency Injection and Mock Objects
Xml Security using Xml Encryption and Xml Digital Signature
Processing...
Buy Java, Deals On Software Technology Store
Click here for great deals on computers, laptops, software and books
Simplifying Java with Jakarta Commons Lang PDF Print
Written by Harshad Oak   
May 17, 2006 at 11:52 PM

As enterprise Java developers, we are routinely required to implement functionality like parsing XML, working with HTTP, validating input, and processing dates. The Jakarta Commons project is an attempt to create components that can take care of all such commonly used tasks, freeing up your time to focus only on core business solutions. In this article we will provide a quick introduction to the Jakarta Commons project and then demonstrate how the Lang component within Jakarta Commons can be used to handle and simplify everyday Java tasks such as string manipulation, working with dates and calendars, comparing data objects, and sorting objects. For all examples, we will use the latest version of Lang, version 2.1.

** First Published on dev2dev

Introduction to Commons and the Lang Component

Jakarta Commons is a project meant solely for reusable Java components. The project has dozens of components for simplifying Java development and addressing one particular requirement well. The range of available components is huge, and they aren't limited for use only in Java applications of a particular type.

The projects are classified into two parts:

  1. Commons Proper: Projects in the Commons Proper can be termed as ready for production use.
  2. Commons Sandbox: Projects in the sandbox are still in the experimental stage.

There are currently 33 projects in the Commons Proper and 22 projects in the works in the Commons Sandbox so there is something in there for every kind of Java project.

The Lang component is one of the more popular components in Jakarta Commons. Lang is a set of classes that you wish were present in J2SE itself.

In this article we will look at some of the most useful features of Lang. Note that you can do everything that Lang does using just the basic Java classes, however it is far easier to use Lang than it is to study, understand, and write the code yourself. Even if you can write superb code, using the tried and tested capabilities of Lang will be quicker and will save considerable review and testing cycle time. Lang comes with proper JUnit test cases and as it is used so widely, it has been well tested by its creators as well as by the real world.

An important feature of Lang is its simplicity. New Java components generally are so complex that unless you know A, B, C, and D technologies, you will not be able to use that component. Often, it is difficult to even understand what a component is trying to achieve, let alone actually use the component. This is not the case with most of the Commons components. Components like Lang are easy to use and very useful to a Java beginner as well as an advanced Java user.

If you need star endorsements before you adopt a technology, try this: Search for commons-lang*.jar in the directory where you keep your Java software. You will be surprised. Tomcat, Struts, Hibernate, Spring, and WebWork are just some of the popular Java projects that make use of Lang.

Let's start with string manipulation with Lang, a task that most Java developers have to do almost every day.




Add This Feed Button

Enter your Email


Java Expert Interviews
JonasJacobiJSFAjax
Pure Ajax creates the next generation legacy applications
RoelStalmanOracleJDeveloper
JDeveloper is the most comprehensive Java IDE available
Mukesh Hegde NCStudio IDE
Java IDE in a brand new avatar. Making development server centric.
Processing...
Go to top of page  Home |
SiteMap

Copyright 2004 to 2008 Rightrix Solutions. All rights reserved. All product names are trademarks of their respective companies. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Rightrix Solutions and IndicThreads.com are independent of Sun Microsystems, Inc.

Views expressed at IndicThreads.com reflect the views of the authors alone, and do not necessarily reflect those of IndicThreads.com. IndicThreads.com and it's authors are not responsible for reader comments and opinions.

Enterprise Java J2EE JEE Portal >> IndicThreads.com