View RSS Feed

All Blog Entries

  1. OMA standard for data synchronisation - SyncML

    by , 11-28-2011 at 08:06 PM (My Java Tips)
    SyncML is the standard for data synchronization and is accepted by Open Mobile Alliance (OMA). All the major players, including Ericsson, Nokia, IBM, Motorola, and Symbian support this protocol.


    The synchronization of data has great importance in today’s world. You carry email applications, contact database, files and other stuff on your handheld devices. It would be great of you can synchronize those with your desktop/notebook. For that there has to be a agreed format.
    ...
    Tags: oma, syncml Add / Edit Tags
    Categories
    Java ME
  2. Using the DocumentBuilderFactory

    by , 11-28-2011 at 08:02 PM (My Java Tips)
    In this post, I will present an example to show how to use the DocumentBuilderFactory.


    First step is to import the required classes.

    Java Code:
    import java.io.File;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
    import java.io.Writer;
    
    // JAXP
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.DocumentBuilderFactory;
    ...
    Categories
    Java EE
  3. Working with the DOM parser

    by , 11-28-2011 at 07:59 PM (My Java Tips)
    You will be introduced to the working of DOM parser in this post.


    We can get a DocumentBuilder instance as soon as we have a DOM factory. The methods available for the DocumentBuilder instance are very similar to those available to its SAX counterpart. But there is a slight difference when we talk about the parse() method. The parse method in case of DOM do not take an instance of the SAX DefaultHandler class. It returns a DOM Document instance representing the XML document that was ...
    Categories
    Java EE
  4. Reading RSS using Informa API

    by , 11-28-2011 at 07:56 PM (My Java Tips)
    RSS (Really Simple Syndication) is a family of Web feed formats used to publish frequently updated content such as blog entries, news headlines, and podcasts. It is actually a specification for XML files to provide syndicated data.


    To read RSS feeds in a Java application is easy. You have to use Informa API which is availabel at:
    http://informa.sourceforge.net/.

    The code snippet given below shows how to read RSS using Informa API.

    Java Code:
    try {
    ...
    Tags: informa, rss Add / Edit Tags
    Categories
    Java EE
  5. Java Compiler API (brief intro)

    by , 11-28-2011 at 07:49 PM (My Java Tips)
    We all know that javac command is used to compile the java classes. Even if we are using some IDE (Eclipse, JBuilder, NetBeans), javac is called at the background for compilation. But with the release of Java 6, it has become possible to compile Java class from a Java class.


    The classes related to Java compiler are packed into javax.tools package.

    There is a class called ToolProvider (javax.tools) whose getSystemJavaCompiler() method returns an instance of some class ...
    Tags: ide, javac Add / Edit Tags
    Categories
    Java SE
  6. Compiling a Java class using JavaCompiler

    by , 11-28-2011 at 07:47 PM (My Java Tips)
    Java 6 introduces a way to compile Java classes from a Java class. In this post, I will present an example to show how this is done.


    I have a Test.java file:

    Java Code:
    public class Test{
    
    public static void main(String[] args) {
            // TODO code application logic here
            System.out.println("Hello World");
    callMe();
    }
        public static void callMe(){
         System.out.println("Hello Babar dost");
    ...
    Categories
    Java SE
  7. Retrieving auto generated key (JDBC 3.0)

    by , 11-28-2011 at 07:41 PM (My Java Tips)
    JDBC 3.0 introduces a lot of interesting and exciting features which makes database programming simpler. In this post, I will address how to retrieve auto generated keys using JDBC 3.0.


    To get the key, simply specify in the statement's execute() method an optional flag denoting that you are interested in the generated value. Flags of your interest are: Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS. Execute the statement and now you can obtain the values of the generated ...
    Categories
    JDBC
  8. Returning multiple results (JDBC 3.0)

    by , 11-28-2011 at 07:38 PM (My Java Tips)
    If you have worked with JDBC 2, you might be knowing that if your statement is returning multiple results, only one ResultSet can be opened at a time. This is a limitation. Good new is that JDBC 3.0 specification allows the Statement interface to support multiple open ResultSets. Lets see hot this can be done.



    Please note that the execute() method closes any ResultSets that were opened from a previous call. To support multiple open results, the Statement interface adds an ...
    Categories
    JDBC
  9. Prepared statement pooling (JDBC 3.0)

    by , 11-28-2011 at 07:35 PM (My Java Tips)
    JDBC 3.0 provides improved connection pooling. This post is all about that.



    It is also possible to pool prepared statements. A prepared statement allows us to keep frequently used SQL statement in a pre-compile form, thus improving performance if that statement is executed multiple times. But there is a dark side of this. Creating a PreparedStatement object introduces a certain amount of overhead. There are some developers sometimes change their object models to increase the ...
    Categories
    JDBC
  10. Transaction savepoints (JDBC 3.0)

    by , 11-28-2011 at 07:32 PM (My Java Tips)
    JDBC 2 provides complete transaction rollback control over transaction. But if you want to rollback to a point, you cannot do so. JDBC 3.0 introduces savepoints which makes this possible.


    JDBC 3.0 provides more control over transactions using savepoints. The Savepoint interface allows us to partition a transaction into logical breakpoints. This in turn provides control over how much of the transaction we wish to rolled back.

    Lets see how to do this. Review the following ...
    Tags: jdbc 2, savepoint Add / Edit Tags
    Categories
    JDBC
  11. Using the JAXP validation framework

    by , 11-28-2011 at 07:29 PM (My Java Tips)
    While working with XML documents, you need to validate the documents. You may use setValidating() method on a SAX or DOM factory. But Java 5.0 (JAXP 1.3) introduces JAXP validation framework which can also be used for validating XML documents.


    Using the JAXP validation framework is fairly simple and efficient. In JAXP 1.3, the validation is broken out into several classes within the new javax.xml.validation package. Lets go through the steps:

    1. Load the model in to ...
    Tags: dom, java 5.0, jaxp, sax Add / Edit Tags
    Categories
    Java EE , XML
  12. XSLT processing in Java

    by , 11-28-2011 at 07:25 PM (My Java Tips)
    XSLT (Extensible Stylesheet Language Transformations) is used to transform XML files into other formats like HTML format. There are many XSLT processors (libraries) available to be used in Java for XSLT transformation. These libraries can be used from a Java application like JSP/Servlet to read a XML file and to transform it into a HTML.


    An XSLT processor takes two inputs: an XML file and an XSLT stylesheet.

    For this post, I have chosen Xalan-Java library for the transformation. ...
    Tags: html, xalan-java, xml, xslt Add / Edit Tags
    Categories
    XML
  13. JAXP SAXParser class

    by , 11-28-2011 at 07:19 PM (My Java Tips)
    You can doa lot if interesting stuff once you have the instance of SAXParser class. I will introduce a code snippet that will show you what you can do with an instance of SAXParser.


    JAXP provides methods to determine the parser's settings. For instance:

    isValidating()
    use this method to see if the parser will perform validation or not

    isNamespaceAware()
    use this method to determine if the parser can process namespaces in an XML document ...
    Categories
    Java EE
  14. SAXParserFactory Example

    by , 11-28-2011 at 07:17 PM (My Java Tips)
    To change the parser implementations, JAXP provides a class called SAXParserFactory. I will present an example that will show how to use this class.


    First thing is to create an instance of SAXParserFactory. After creating the new instance, we have to get he SAX-capable parser. For thos, factory provides a method. Good thing is that the JAXP implementation takes care of the vendor-dependent code and thus keeps the code clean. This factory has some other nice features, as well. Do explore ...
    Categories
    Java EE
  15. Introduction to JAXP

    by , 11-28-2011 at 07:14 PM (My Java Tips)
    If you want to process XML data using applications written in the Java programming language, then JAXP is the best choice. JAXP stands for Java API for XML Processing. I will introduce JAXP in this post.


    JAXP can be called an abstraction layer since it does not introduces any new way to parse XML documents nor it provides different way of handling XML documents. Actually it makes using DOM and SAX easier. Using JAXP, you may habdle vendor-specific tasks that may arise when dealing ...
    Tags: dom, jaxp, sax Add / Edit Tags
    Categories
    Java EE
  16. Java Web Start (advantages)

    by , 11-28-2011 at 07:12 PM (My Java Tips)
    Ever thought of launching full-featured Java applications with a single click? Java Web Start provided with Java Standard Edition (J2SE™), version 5.0 helps making this possible. In this post, I will introduce you to this new and exciting feature.


    Java Web Start simplifies a lot of things. For instance a complete spreadsheet program or an Internet chat client normally involves going through complicated installation procedures. But with Java Web Start, you can download and launch applications ...
    Categories
    Java Web Start
  17. Creating the JNLP File (Java Web Start)

    by , 11-28-2011 at 07:08 PM (My Java Tips)
    If you plan to run an application with Java Web Start, you have to create JNLP (Java Network Launching Protocol) file. In this post, I will briefly explain how to do that.


    The JNLP file is an XML file and it contains elements and attributes that tell Java Web Start how to run the application.

    Presented below is a JNLP file for the Notepad application:

    <!--?xml version="1.0" encoding="utf-8"?-->
    Java Code:
    <jnlp spec="1.0">codebase="URL
    ...
    Tags: jnlp file, xml Add / Edit Tags
    Categories
    Java Web Start
  18. Accessing Resources in a JAR File

    by , 11-28-2011 at 07:05 PM (My Java Tips)
    JAR files are used to deploy applications. They comprise of java classes and other resources like images etc. In this post, I will explain how to access resources packed in a JAR file.



    To access resources in a JAR file, we use getResource method. Lets do this practically. The code snippet provided shows how to retrieve images from a JAR file.

    Java Code:
    // Get current classloader
    ClassLoader cl = this.getClass().getClassLoader();
    // Create icons
    ...
    Categories
    Java SE
Page 31 of 48 FirstFirst ... 21293031323341 ... LastLast