Archive

Archive for the ‘Java’ Category

Java 5 Features

Java 5 Features

Generics
This long-awaited enhancement to the type system allows a type or method to operate on objects of various types while providing compile-time type safety. It adds compile-time type safety to the Collections Framework and eliminates the drudgery of casting. Refer to JSR 14.
Enhanced for Loop
This new language construct eliminates the drudgery and error-proneness of iterators and index variables when iterating over collections and arrays. Refer to JSR 201 .
Autoboxing/Unboxing
This facility eliminates the drudgery of manual conversion between primitive types (such as int) and wrapper types (such as Integer). Refer to JSR 201 .
Typesafe Enums
This flexible object-oriented enumerated type facility allows you to create enumerated types with arbitrary methods and fields. It provides all the benefits of the Typesafe Enum pattern (“Effective Java,” Item 21) without the verbosity and the error-proneness. Refer to JSR 201.
Varargs
This facility eliminates the need for manually boxing up argument lists into an array when invoking methods that accept variable-length argument lists. Refer to JSR 201.
Static Import
This facility lets you avoid qualifying static members with class names without the shortcomings of the “Constant Interface antipattern.” Refer to JSR 201.
Metadata (Annotations)
This language feature lets you avoid writing boilerplate code under many circumstances by enabling tools to generate it from annotations in the source code. This leads to a “declarative” programming style where the programmer says what should be done and tools emit the code to do it. Also it eliminates the need for maintaining “side files” that must be kept up to date with changes in source files. Instead the information can be maintained in the source file. Refer to JSR 175.

Read Data From Excel using Java, POI

December 31, 2009 Leave a comment

1. Get poi*.jar from Download POI JAR
2. Use this Java Program to read Data in Excel file By Column by Column

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import java.util.Iterator;

// This is a simple java program to generate sql script from excel file contains values

public class POIExcelReader
{
StringBuilder query = new StringBuilder(“INSERT INTO tablename (Name, URL, Age) VALUES \n\n”);

public POIExcelReader()
{}

public void displayFromExcel (String xlsPath)
{
InputStream inputStream = null;

try
{
inputStream = new FileInputStream (xlsPath);
}
catch (FileNotFoundException e)
{
System.out.println (“File not found in the specified path.”);
e.printStackTrace ();
}

POIFSFileSystem fileSystem = null;

try
{
fileSystem = new POIFSFileSystem (inputStream);

HSSFWorkbook      workBook = new HSSFWorkbook (fileSystem);
HSSFSheet         sheet    = workBook.getSheetAt (0);
Iterator<HSSFRow> rows     = sheet.rowIterator ();

while (rows.hasNext ())
{
HSSFRow row = rows.next ();

HSSFCell nameCell = row.getCell((short)0);
HSSFCell ageCell = row.getCell((short)1);
HSSFCell urlCell = row.getCell((short)2);

query.append(“(‘”+nameCell.getStringCellValue()+”‘, “+
“‘”+urlCell.getStringCellValue()+”‘, “+
“”+Math.round(ageCell.getNumericCellValue() )+”),  \n”);

}
}
catch (IOException e)
{
e.printStackTrace ();
}
}

public static void main (String[] args)
{
POIExcelReader poiExample = new POIExcelReader();
String         xlsPath    = “c:\\pe_ip.xls”;

poiExample.displayFromExcel (xlsPath);

poiExample.query.append(” \n); “);
System.out.println(poiExample.query.toString());
}
}

3. OUTPUT

U will get output like this

INSERT INTO tablename (Name, URL, Age) VALUES
(‘aaa’, ‘www.aaa.com’, 25),
(‘bbb’, ‘www.bbb.com’, 25),
(‘ccc’, ‘www.ccc.com’, 98)
);

When input excel file [ screenshot]

Servlets Video Tutorial -2

Categories: Servlets

JDK 7 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 current 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.

Comments to: jdk7-dev at openjdk.java.net

Summary

Features are listed in order, more or less, from lowest to highest in the overall JDK  software stack.

VM
Compressed 64-bit object pointers
A technique for compressing 64-bit pointers to fit into 32 bits, which decreases memory and memory-bandwidth consumption and thereby improves performance (VM-level feature)
Links: wiki page
Milestone target: M1
Garbage-First GC (G1)
A new garbage collector that promises to achieve lower pause times and better predictability than the current CMS collector (VM-level feature)
Milestone target: M1
JSR 292: VM support for non-Java languages (InvokeDynamic)
VM extensions to support the implementation of non-Java languages at performance levels near to that of the Java language itself
Lead: John Rose
Milestone target: M3
Language
JSR 308: Annotations on Java types
An extension to the Java annotation syntax to permit annotations on any occurrence of a type
Milestone target: M4
JSR TBD: Small language enhancements (Project Coin)
A set of small language changes intended to simplify common, day-to-day programming tasks
Lead: Joe Darcy
Milestone target: M6
JSR 294: Language and VM support for modular programming
Enhancements to the Java language and virtual-machine specifications to support modular programming, at both compile time and run time
Core
Modularization (Project Jigsaw)
An implementation-specific, simple, low-level module system focused upon the goal of modularizing the JDK, and the application of that system to the JDK itself
Upgrade class-loader architecture
Modifications to the ClassLoader API and implementation to avoid deadlocks in non-hierarchical class-loader topologies
Links: summary
Milestone target: M3
Method to close a URLClassLoader
A method that frees the underlying resources, such as open files, held by a URLClassLoader
Links: summary; api
Milestone target: M2
Unicode 5.1
Upgrade the supported version of Unicode to 5.1
Milestone target: M3
Concurrency and collections updates (jsr166y)
A lightweight fork/join framework, generalized barriers and queues, a concurrent-reference HashMap, and fences to control fine-grained read/write ordering
Lead: Doug Lea
JSR 203: More new I/O APIs for the Java platform (NIO.2)
New APIs for filesystem access, scalable asynchronous I/O operations, socket-channel binding and configuration, and multicast datagrams
Milestone target: M2
SCTP (Stream Control Transmission Protocol)
An implementation-specific API for the Stream Control Transmission Protocol on Solaris
Milestone target: M3
SDP (Sockets Direct Protocol)
Implementation-specific support for reliable, high-performance network streams over Infiniband connections on Solaris
Milestone target: M3
Elliptic-curve cryptography (ECC)
A pure-Java implementation of the standard Elliptic Curve Cryptographic (ECC) algorithms, so that all Java applications can use ECC out-of-the-box
Milestone target: M5
Client
XRender pipeline for Java 2D
A new Java2D graphics pipeline based upon the X11 XRender extension, which provides access to much of the functionality of modern GPUs
Forward-port 6u10 features
Forward-port implementation-specific features from the 6u10 release: The new Java Plug-In, Java Kernel, Quickstarter, related installer features, and the Swing Nimbus look-and-feel
Milestone target: M4
Create new platform APIs for forward-ported 6u10 features
Create new platform APIs for features originally implemented in the 6u10 release: Translucent and shaped windows, heavyweight/lightweight mixing, and the improved AWT security warning
Milestone target: M3
JSR 296: Swing application framework
An API to define the basic structure of a typical Swing application, thereby eliminating lots of boilerplate code and providing a much-improved initial developer experience
Links: JSR 296
Milestone target: M5
Swing updates
Small additions to the Swing API including the JXLayer component decorator, JXDatePicker, and possibly CSS-based styling
Enterprise
Update the XML stack
Upgrade the JAXP, JAXB, and JAX-WS APIs to the most recent stable versions
Milestone target: M5
Categories: Java Tags:

JSP Video Tutorial – 1

March 25, 2009 Comments off

Servlets Video Tutorials – 2

March 25, 2009 Comments off

Java Servlets Video Tutorials

March 25, 2009 Comments off

JavaFX

February 27, 2009 Leave a comment

RIA – rich internet application api/framework from SUN. the Java Nestle

Refer :  www.javafx.com

Categories: Java Tags:
Follow

Get every new post delivered to your Inbox.