Monday, August 31, 2009

WHAT'S NEW IN JAVA

JDK 7

Java Development Kit 7 (JDK 7) is the next major release of the Java SE platform. Through the Open JDK project, JDK 7 has been a highly collaborative effort between Sun and volunteers from the Java developer community. Sun extends its gratitude to all who have contributed to this release.
Learn about some of the new and cool features in the next release of the Java Development Kit, JDK 7.
In this Deep Dive, Danny Coward, Chief Architect for Client Software at Sun Microsystems, highlighted some of the significant new features in JDK 7. Some of these features focus on modularizing the JDK, supporting non-Java languages at the VM level, and making developers more productive through various small changes to the Java languages. Danny backed up this discussion with some code examples and demonstrations.

JDK 7 introduces several key features to improve performance, usability, and security of the Java platform. A detailed list of these features appears on the Open JDK site.
Based on the feedback from the developer community and Sun's customers, the JDK 7 features primarily focus on the following areas.

Features

This is the list of features being developed by Sun, and others, for JDK 7.
When the Java SE 7 Platform JSR is submitted then these features will be proposed therein, except for those listed as either VM-level or implementation-specific.
Per the draft of the development process we will shortly publish a Feature Proposal template. That will be the vehicle for proposing additional features for inclusion in the release. Smaller, non-feature changes will go through a lighter-weight process, soon to be defined.

JDK 7 Development Process

In the continuing transition of JDK development activities to a more
open, collaborative model, we're going to completely revise the JDK
development process. The sketch presented here is based on the past
thirteen years of the Sun JDK team's experience, seasoned by ideas and
lessons learned from other, mainly non-Sun projects.
This is just a first draft. There's no one obviously "right" way to
design this sort of process; this is a starting point. Comments are,
as always, most welcome: jdk7-dev at openjdk dot java dot net.
This process is more involved than that of many free-software or
open-source projects. This is a result of the JDK team's strong
commitment to the highest standards of quality, compatibility, and
performance, and also the fact that we're maintaining and evolving not
just a large body of code but, simultaneously, the specification of one
of the world's most widely-used programming platforms.
Ultimately we will leverage our new Bugzilla instance to automate the
tracking of the various review and approval paths defined here. That's
an implementation detail, however; for now let's focus on getting the
process into a workable form.

Modularization

A large-scale effort to re factor, or break up, the Java SE platform into smaller, separate, interdependent modules. Individual modules can then be downloaded as required by the Java virtual machine and/or Java applications. This effectively shrinks the size of the runtime on the user's machine.
One benefit of modularization is that the platform is a smaller download, potentially improving start-up performance. Having a smaller memory footprint also enables significant performance improvements, especially for desktop applications. A smaller platform also means it can now fit on devices with less memory.

Multi-Language Support

Improves compatibility between Java and various dynamic languages, such as Ruby and Python, by providing better-than-native implementations of these languages on top of the Java Runtime Environment (JRE).
Refer to JSR 292, also called "Invoke Dynamic". This JSR defines the elements critical for Ruby, Python, and other dynamic languages to be addressed for JDK 7.

Developer Productivity

JDK 7 will also include several features to enhance developer productivity. One of Sun's goals is to make JDK 7, and other versions of the JDK, as developer-friendly as possible.

Performance

Sun understands the need to improve the performance of the Java SE platform, and several features in JDK 7 address just that.
The new Garbage First (G1) Garbage Collector is a low pause, server-style garbage collector that will eventually replace the Concurrent Mark-Sweep (CMS) garbage collector. G1's primary advantage over CMS is incremental compaction, better predictability, and ease of use.
Click here for more information.

By - Ramesh


Please find more topics under JASe Archive!!!

PRODUCT AND TECHNOLOGY RELEASES

Java Server Faces

Java Server Faces technology is a framework for building user interfaces for web applications.

Java Server Faces technology includes:

Java APIs to represent UI components, manage state, handle events, and validate input. The API has support for internationalization and accessibility.

Two JSP custom tag libraries for expressing user interface (UI) components within a JSP page, and for wiring components to server-side objects. Page authors can easily add UI components to their pages.

Java Server Faces technology is based on the Model View Controller (MVC) architecture for separating logic from presentation, so if you have been practicing this, you'll feel at home with JSF.
A JSF application is just like any other Java technology-based web application; it runs in a Java Servlet container, and contains:

JavaBeans components (or model objects) containing application-specific functionality and data

Event listeners -- JSP pages
Server-side helper classes
A custom tag library for rendering UI components
A custom tag library for representing event handlers and validators
UI components represented as stateful objects on the server
Validators, event handlers, and navigation handlers.
Application configuration resource file for configuring application resources

One of the advantages of JSF is that it is based on the Model View Controller (MVC) architecture, to offer a clean separation between presentation and logic. This may ring a bell for those who are using existing web frameworks such as Struts. However, note that JSF and Struts are not competing technologies, and in fact, they interoperate together. JSF, however, does have some advantages over Struts.
For example, in Struts there is only one way to render an element, while JSF provides several mechanisms for rendering an individual element. It is up to the page designer to pick the desired representation, and the application developer doesn't need to know which mechanism was used to render a component
The author of Struts, Craig McClanahan, is also the co-specification lead for JSF, as well as an employee of Sun Microsystems.

Advantages

The primary benefits of Java Server Faces technology include:

Ease-of-Use: Several aspects of the Java Server Faces architecture contribute to its ease-of-use. For one, Java Server Faces technology offers a clean separation between logic and presentation, enabling a wide range of users -- from web-page designers to component developers-- to take advantage of Java Server technology, resulting in a division of labor and a shorter development cycle. Also, a user-interface created with Java Server Faces technology handles all the complexities of user-interface management, including input validation, component-state management, page navigation, and event handling.

Standardization: Java Server Faces technology is being developed through the Java Community Process. Several prominent, respected tools vendors are contributing members of the expert group and are committed to supporting Java Server Faces technology in their tools.

Device Independence: Java Server Faces technology is designed to be flexible. By defining only component functionality in extensible UI component classes, the Java Server Faces architecture allows component developers to extend the component classes to generate their own component tag libraries targeted for specific clients.

How to Create a Java Server Faces (JSF) Development Environment w Apache Tomcat + Suns JDK



By - Feizal



Please find more topics under JASe Archive!!!

TIPS AND TRICKS

Generate PDF files from Java applications dynamically

Many applications demand dynamic generation of PDF documents. Such applications range from banks generating customer statements for e-mail delivery to readers buying specific book chapters and receiving them in PDF format.

Get familiar with iText

iText is a freely available Java library from Lowagie.com. The iText library is powerful and supports the generation of HTML, RTF, and XML documents, in addition to generating PDF's. You can choose from a variety of fonts to be used in the document. Also, the structure of iText allows you to generate any of the above-mentioned types of documents with the same code.
The iText library contains classes to generate PDF text in various fonts, generate tables in PDF document, add watermarks to pages, and so on. There are many more features available with iText. It would not be possible to demonstrate all of them in a single article. We will cover the basics required for PDF generation.

How to configure with Eclipse:

Downloading and configuring iText in Eclipse
Being a pure Java library, iText comes in the form of a JAR file which you download from Lowagie.com. Once you have downloaded the library (let's say, at path C:\temp), the following steps will configure the iText library in an Eclipse environment:
Create a new Java project in Eclipse named iText.
Right-click on the iText project in Package Explorer view and select Properties
Click Java Build Path. On the Libraries tab, click Add External Jar's.
Browse to the C:\temp directory and select the itext-1.3.jar in this directory.
Click OK.
iText is now configured, and Eclipse is ready to create Java applications to generate dynamic PDF documents.

By - Ramesh

Selecting the Best Java Collection Class for Your Application

• All Vector methods are synchronized as are Stack methods
• Array List fast operations are getting the size of the list, getting the object at a specified position in the list, and setting the object at a specified position in the list.

• Linked List can quickly insert or remove objects in the middle of the list whereas Array List takes time proportionate to the number of objects in the list after the position to which objects being added or removed. Use Array List unless you are inserting or deleting a lot from the middle of a list.

• If you rarely iterate an Array List object while it is being modified, then using a lock is a good solution. However, if iterating over a Array List while modifying it is common, then locking may make waiting time unacceptably high.

• With CopyOnWrite ArrayList all operations that change the contents of a CopyOnWriteArrayList collection cause the underlying array to be replaced with a copy of itself before the contents of the array are changed. Any active iterators will continue to see the unmodified array, so there is no need for locks.

• HashSet is faster than TreeSet, so only use the TreeSet preferentially when you need elements to remain in sorted order.
• HashSet is faster than LinkedHashSet so only use the LinkedHashSet preferentially when you need elements to remain in insertion order.

• ConcurrentSkipListSet keeps it's elements in sorted order and is thread-safe and usually preferable to a synchronized wrapped set.

• With CopyOnWriteArraySet all operations that change the contents of a CopyOnWriteArraySet collection cause the underlying array to be replaced with a copy of itself before the contents of the array are changed. Any active iterators will continue to see the unmodified array, so there is no need for locks.

• PriorityQueue add and remove methods take time that is proportionate to the number of objects in the queue. Queues based on the PriorityQueue class do not block. PriorityBlockingQueue is similar in performance but does block.

• DelayQueue is a specialized blocking queue that consults the objects it contains as to when they can be removed from the queue.

• A SynchronousQueue object is always empty; the put method blocks unless another thread is waiting for the object's take method to return.

• If you are not interested in how objects will be organized in a collection, then the only other consideration is performance. In that case, use the ArrayList class. It is fast and makes efficient use of memory.

By - Amaresh


Please find more topics under JASe Archive!!!