There are two approaches to load jar files not from (web-inf/lib)
Step1: Create lib folder inside DAMS-Ear/Ear Content. Place the required jar files inside the lib. JBoss will by default add all these jars to classpath of the application and make them available.
Step2: Add dependent or component jars in application.xml file in Ear and deploy the web-app
<?xml
version="1.0"
encoding="UTF-8"?>
<application
id="Application_ID"
version="1.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>DAMS-Ear</display-name>
<module
id="WebModule_1233318064937">
<web>
<web-uri>DAMS-Web.war</web-uri>
<context-root>DAMS-Web</context-root>
</web>
</module>
<module
>
<java>DAMS-xxx.jar</java>
</module>
</application>
We add each module as shown above
Note: In eclipse Ear shows errors but application is deployed
Let me know if you have any queries…..
Saturday, January 31, 2009
Approaches to load jar files
Posted by RAM at 3:54 PM 0 comments
Labels: approaches to load jar files, jar fiels loading, jar files
Wednesday, January 21, 2009
JAVAFX
Article 1: JavaFX Script is a highly productive scripting language that enables content developers to create rich media and content for deployment on Java environments. JavaFX Script is a declarative, statically typed programming language. It has first-class functions, declarative syntax, list comprehensions, and incremental dependency-based evaluation. It can make direct calls to Java platform APIs. that are on the platform. Although JavaFX Script makes it very easy to create simple GUIs, it is designed to be capable of supporting GUIs of any size or complexity. JavaFX Script is statically typed, so it has the same code structuring, reuse, and encapsulation features (such as packages, classes, inheritance, and separate compilation and deployment units) that make it possible to create and maintain very large programs using Java technology.In addition, JavaFX Script is intended to have the same level of IDE/tool support that Swing programmers are familiar within Java technology: an editor with code completion, refactoring, a Javadoc-like documentation tool, a source-level debugger, a profiler, and ultimately a visual builder.JavaFX Script will work with all major IDEs, including NetBeans, which is the reference implementation IDE for Java development.JavaFX Script is specifically designed to optimize the creative process of building rich and compelling UIs, leveraging Java Swing, Java 2D, and Java 3D for developers and content authors. These RIAs and next-generation services that can be proliferated across virtually any device — from phonetop or desktop browsers and mobile devices, to set-top boxes and Blu-ray Discs — securely and without local installation.JavaFX Script applications will run on JavaFX Mobile software, making these types of applications a reality for the mobile wo Article 2: What is JavaFX?JavaFX is a new family of Sun products based on Java technology and targeted at the high impact, rich content market. What is being announced at the 2007 JavaOne Conference around JavaFX?At the Conference, Sun Microsystems is announcing two products in the JavaFX family: JavaFX Script and JavaFX Mobile. JavaFX Script is a a highly productive scripting language for content developers to create rich media and content for deployment on Java technology. JavaFX Mobile is a complete mobile operating and application environment built around Java and Linux open source technologies. How does JavaFX Script compare with other tools for creating rich internet applications (RIAs)?Today's Internet offers a world of possibility for those who can quickly develop and deploy rich internet applications (RIAs). But only the Java platform is pervasive enough on mobile devices and browsers to effectively marry client- and browser-based technologies with RIAs enabling applications to run on multiple platforms virtually unchanged. JavaFX is Sun's new product family that addresses this market. JavaFX Script will enable developers to more quickly and easily develop RIAs and next-generation services that can be proliferated across virtually any device -- from desktop browsers and mobile devices, to set-top boxes and Blu-ray Disc DVDs – securely and without local installation. JavaFX Mobile software makes these type of applications a reality for the mobile world. Will there be other products in the JavaFX family?Sun is planning several products in this family. More details will follow as they become available. Where can I obtain JavaFX Script or more information?More information on JavaFX Script is available at www.sun.com/javafx. The alpha code that Sun is demoing at the JavaOne Conference is available at Project OpenJFX (openjfx.dev.java.net). Sun will be expanding this scripting language and is inviting developers to join the OpenJFX community and participate with their feedback. Tell me more about JavaFX Script.JavaFX Script is a highly productive scripting language that enables content developers to create rich media and content for deployment on Java environments.JavaFX Script is a declarative, statically typed programming language. It has First-class functions, declarative syntax, list-comprehensions, and incremental dependency-based evaluation. It can make direct calls to JavaAPIs that are on the platform. Since JavaFX Script is statically typed, it has the same code structuring, reuse, and encapsulation features (such as packages, classes, inheritance, and separate compilation and deployment units) that make it possible to create and maintain very large programs using Java technology. Why is the JavaFX Script name so long?Although the official name of the scripting language is JavaFX Script, we expect many programmers to just call it JavaFX as it is the core of the JavaFX family. Why did you create another scripting language?JavaFX Script is specifically designed to optimize the creative process of building rich and compelling UIs leveraging Java Swing, Java 2D and Java 3D for developers and content authors. Will JavaFX be open sourced?Yes, JavaFX Script will be open sourced. The governance, licensing, and community models will be worked out as product release draws closer. Can I contribute to JavaFX?Absolutely. Join the OpenJFX community on Java.net. Currently, Sun is looking for your feedback and the directions in which you would like to see JavaFX Script evolve. Once the basic prototype phase is completed, Sun will provide additional details on how you can contribute to the technology itself. Will development tools support JavaFX Script?JavaFX Script will initially work with the NetBeans IDE, but it is expected to work with other IDEs as well. Why do I need the JavaFX Script? Isn't Swing good enough?There's nothing wrong with Swing. Swing is one of the best GUI development toolkits of its kind. Swing makes it very easy to create standard GUI components, buttons, listboxes, trees, and tables. Together with Java 2D, Swing makes it easy to customize existing components or to create new custom components to achieve virtually any desired visual effect. Sun is not replacing Swing with JavaFX; instead, JavaFX Script makes Swing much easier to use.With the new JavaFX Script language, the structure of the programmer's code closely matches the actual layout of the GUI, making it tangibly easier to understand and maintain. Why isn't Groovy enough?Groovy and other languages have two specific traits which don't precisely meet these needs, namely that they are generic in nature and don't provide the appropriate abstractions necessary to optimize the UI design process and similarly are designed specifically for programmers other than content authors. What about performance? Isn't using a scripting language going to be a problem?Performance is obviously an important issue. The architecture of JavaFX Script is meant to be highly performant. For example, the GUI components and back-end application objects are implemented in Java; JavaFX Script code is used only to create such components, configure them, and wire them together. In addition, since the JavaFX Script implementation handles event generation and dispatching, it can be optimized and all Swing applications built with JavaFX Script will benefit. Without JavaFX Script, programmers must effectively handcraft their own incremental evaluator for each new application -- adding property change listeners to and firing events from Java Beans, adding listeners to GUI components, and then determining what events need to fired and/or handled by each bean or component. These steps tend to be very error prone and difficult for programmers to optimize. Is JavaFX Script only for simple GUIs?Although JavaFX Script makes it very easy to create simple GUIs, it is designed to be capable of supporting GUIs of any size or complexity. Unlike many other Java scripting languages, JavaFX Script is statically typed and has the same code structuring, reuse, and encapsulation features (such as packages, classes, inheritance, and separate compilation and deployment units) that make it possible to create and maintain very large programs in Java. In addition, JavaFX Script is intended to have the same level of IDE/tool support that Swing programmers are familiar with in Java: an editor with code completion, refactoring, a Javadoc-like documentation tool, a source-level debugger, a profiler, and ultimately a visual builder. Will JavaFX Script applications run on Java on the desktop?JavaFX Script applications run on the Java Runtime Enviroment (JRE) on the desktop. Will JavaFX Script applications run on JavaFX Mobile?Yes, that is why JavaFX Mobile is being announced simultaneously. Weitere Informationen: www.sun.com/ software/ javafx
Posted by RAM at 9:00 PM 0 comments
Labels: java javafx, javafx, javafx ram, sun
STRUTS 2 CUSTOM VALIDATIONS
Custom Validations :(Prepared by Appaji,senior software engineer) Requirements: Custom validations are required if default validations are not sufficient to fulfill the needs.
Struts 2 allows the use of Custom validators through the @CustomValidator annotation
Framework used:struts2
Approach:
1. In existing struts project add the fallowing code in jsp
<s:actionerror/>
<s:fielderror/>
<s:textfield
name="price"
size="20"
label="price"/>
2. Add CustomValidator to setPrice() method.
The @CustomValidator annotation takes two parameters, type and message
<?xml
version="1.0"
encoding="UTF-8"?>
<!DOCTYPE
validators
PUBLIC
"-//OpenSymphony Group//XWork Validator Config 1.0//EN"
"http://www.opensymphony.com/xwork/xwork-validator-config-1.0.dtd">
<validators>
<validator
name="pricefield"
class="com.gdas.gdas.web.action.PriceValidator"/>
</validators>
note:dont include existing validators inside validators.xml
4. Create PriceValidator by extending the FieldValidatorSupport class
import
org.apache.struts.action.ActionErrors;
import
org.apache.struts.action.ActionMessages;
import
org.apache.struts2.components.ActionError;
import com.opensymphony.xwork2.validator.ValidationException;
import com.opensymphony.xwork2.validator.Validator;
import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; public
class PriceValidator extends FieldValidatorSupport {
@Override
public
void validate(Object object) throws ValidationException {
String fieldName = getFieldName();
Object value = this.getFieldValue(fieldName, object);
System.out.println("fieldName-->"+fieldName+"value-->"+value);
if(value==null) {
setDefaultMessage("You enter null");
addFieldError(getDefaultMessage(), object);
return ;
}
if((Integer)value==111) {
setDefaultMessage("You enter 111");
addFieldError(getDefaultMessage(), object);
return ;
}
try {
Integer price=(Integer)value;
return;
}catch(Exception e) {
addFieldError(fieldName, object);
}
}
}
The addFieldError method is used add any failed validations to the list of errors to be displayed.
The getFieldName and getFieldValue methods are implemented in the superclasses to retrieve the field name and field value for the field beign validated.
The custom validator may extend the FieldValidatorSupport or the ValidatorSupport classes.
Let me know if you have any queries on this,
Regards ,
Appaji,
Posted by RAM at 6:11 PM 2 comments
Labels: CUSTOM VALIDATIONS, GETDEFAULTMESSAGE through Validator class, STRUTS2
JAVA VERSION NAMES
JAVA VERSION CODE NAME N RELEASE DATE
Version Description of Code Name Code Name Date of Release JDK 1.1.4 Sparkler Sept 12, 1997 JDK 1.1.5 Pumpkin Dec 3, 1997 JDK 1.1.6 A female character in Bible Abigail April 24, 1998 JDK 1.1.7 Roman cognomen used by several politicians Brutus Sept 28, 1998 JDK 1.1.8 Name of a person/Football club Chelsea April 8, 1999 J2SE 1.2 Playground Playground
Dec 4, 1998 J2SE 1.2.1 (none) March 30, 1999 J2SE 1.2.2 Cricket July 8, 1999 J2SE 1.3 Kestrel
May 8, 2000 J2SE 1.3.1 Ladybird
May 17, 2001 J2SE 1.4.0 Merlin Feb 13, 2002 J2SE 1.4.1 Hopper Sept 16, 2002 J2SE 1.4.2 Mantis June 26, 2003 J2SE 5.0 (1.5.0) Tiger Sept 29, 2004 Java SE 6 Mustang Java SE 7 Dolphin You can these names on the sun website.
Here is the brief history of java. Some of you wanted to know that how many packages are there in java when it is officially released well here are the some facts.
Java 1.0 - 212 classes in 8 packages
Java 1.1 - 503 classes in 23 packages
Java 1.2/2.0 - 1,520 classes in 59 packages
Java 1.3 - 1842 classes in 76 packages
Java1.4 - 2991 classes in 135 packages
Java 5.0 - 3562 classes in 166 packages
Posted by RAM at 2:30 PM 3 comments
Tuesday, January 20, 2009
Generate PDF files from Java Applications dynamically
Generate PDF files from Java Standalone/Web Applications dynamically
IText is a freely available Java library from Lowagie.com. The iText library is powerful to generating PDFs.
Pre-requisites:
Optional (If we need to align text as traditional format):
1.itext-hyph-xml.jar (To download http://sourceforge.net/project/showfiles.php?group_id=15255&package_id=151860&release_id=326129)
Configuring iText in Eclipse :
Being a pure Java library, iText comes in the form of a JAR file . 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:
OR
Place itext-2.1.4.jar file into your project lib folder (eg:
G:\eclipseworkspace\Apps-Web\WebContent\WEB-INF\lib)
The com.lowagie.text.Document is the main class for PDF document generation. This is the first class to be instantiated. Once the document is created, we would require a writer to write into it. The com.lowagie.text.pdf.PdfWriter is a PDF writer. Some of the other commonly used classes are given below:
Basic Steps to do:
/* Simple HelloWorld.java program */
Step 1: Create a Document.
Step 2: Get a DocWriter instance (in this case, a PdfWriter instance)
Step 3: Open the Document.
Step 4: Add content to the Document.
Step 5: Close the Document.
Document document = new Document(); ------àStep 1
try {
PdfWriter.getInstance(document,new FileOutputStream("HelloWorld.pdf")); --------àStep2
document.open(); -----------------àStep3
document.add(new Paragraph("Hello World")); ---------------àStep4
} catch (Exception e) {
// handle exception
}
document.close(); ------------àStep5
let me know if you have any queries on this(IText).
Regards,
Cheekuri.
Posted by RAM at 3:18 PM 1 comments
IMage TO PDf Conversion Tool
Steps to convert Image (taking the input from scanner) to Pdf format
Step1: Installation of the application “Image2PDF v3.2 “
· download url: http://www.verypdf.com/tif2pdf/tif2pdf.htm
· save into our local system
· Run the application
· Configure the setting as we needed(we can customizable settings if needed)
Step2: Integration with our Application
By calling Process of this application whenever we needed in Application using Java by placing tabs or buttons or links.
Sample code: Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("C:/Program Files/VeryPDF Image2PDF v3.2/Image2PDF.exe");
);
Main features:
You can take the input from the scanner and storing into Storage location directly using this.
Input: Hardcopy of any document to upload as PDF file.
Output: Storing as pdf file into file system.
You can convert image files to pdf files by selecting the source location or drag the file from windows explorer to tool.
Image To PDF Features (Document)
Supports TIF, TIFF, JPG, JPEG, PNG, GIF, PCD, PSD, TGA, BMP, DCX, PIC, EMF, WMF, etc. image formats
Combines multiple directories and images into one PDF file
Does NOT need Adobe Acrobat software
Supports Win98/ME/NT/2000/XP/2003/Vista platforms
Supports Multi-page image file to PDF conversion
Supports sorting on file name when converting batches
Image files can be dragged directly from Windows Explorer and converted quickly
Supports single file processing, single directory processing, multi-level directory processing and many others
Set automatic despeckling (of B/W images; removes noise) and skew-correction
Merge several image files into a single PDF file during batch converting, or convert each image file into individual PDF file
Makes use of effective compression processing to minimize space occupied by the created PDF files; for example, an A4 paper size TIFF file with a B/W image the output size is about 40KB to 50KB per page; color and gray-scale images are also compressed and optimized
Drag and drop image files
Password protection for PDF files with 40 or 128 bit encryption
Set file permissions to restrict printing, copying, and future modifications to the document
Automatically open PDF file after creation
Specify any resolution in the generated PDF file
Optimized to increase speed
Set the document title, subject, author and keywords
Supports scanner
Supports monitor multiple directories
Supports generate bookmarks
Supports merge to an existing PDF file (insert before the first page or append to the last page)
Note: Trial version for limited usage.
Registered version for life time and unlimited (Purchasing cost is $38).
Posted by RAM at 11:51 AM 0 comments