View RSS Feed

Most Popular Blogs

  1. Java ArrayList : Generics & Sorting

    by , 07-21-2011 at 07:20 AM


    Abstract

    Java ArrayList (ArrayList (Java 2 Platform SE 5.0)) class is a fastest and easiest way to represent one-dimensional array. ArrayList not synchronized, that is cross thread access may cause problems. It holds an ordered item sequence of items (objects) like an array, but there are differences:

    • Size of an ArrayList could change dynamically, by adding or removing elements
    • An ArrayList can hold only object references, not primitives

    ...
    Attached Thumbnails Attached Files
  2. Fetching contact field (PIM)

    by , 11-06-2011 at 07:07 PM (My Java Tips)
    Each contact entry in a PIM Contact database is represented by Contact. This post is all about retrieving contact fields from PIM.


    The supported field list for a Contact depends on vCard specification from the Internet Mail Consortium. These set of fields included in this Contact class provides relevant information about a contact. ContactList restricts what fields a Contact can retain. This reflects that some native Contact databases do not support all o the fields available in a ...
    Categories
    Java ME
  3. Asynchronous method calls

    by , 11-07-2011 at 07:52 PM (My Java Tips)
    Methods called on the asynchronous proxy will be executed asynchronously, and the results can be obtained later on.


    To execute methods asynchronously in EJB 3.0, one can use asynchronous proxy. This allows calling methods at an instance, and collecting the results later. Good thing is that there exist a JBoss extension to EJB 3.0, which allows obtaining asynchronous proxy from the remote or local interface of a stateful session bean, stateless session bean or service bean.
    ...
    Categories
    EJB
  4. Configuring Data Sources in Spring

    by , 11-27-2011 at 10:51 PM
    Spring offers a number of options for configuring a data sources via data source beans. These sources include the following:
    • Data sources that use JNDI
    • Data sources that use JDBC drivers
    • Data sources that pool connections


    There is significant differences in the features available depending on what you are trying to do. In this tip, I will outline how to configure different data sources and what they are best used for.

    If you are looking to do really robust ...
  5. Using Spring Web Flow Part 1

    by , 11-30-2011 at 05:52 AM
    In a previous article, I gave an introduction to Spring Web Flow. In this article, I will delve into the details of how to use Spring Web Flow.

    In Spring Web Flow, a flow is defined by three primary elements: states, transitions, and flow data. States are points in a flow where something happens. Consider if you want to plan a short holiday in Florence. You need to first choose your flights, then you choose your hotel, you might also choose a car, etc. Similarly, as a flow progresses, ...
  6. Is JSP variable declaration thread safe?

    by
    JSP
    , 01-01-2012 at 07:20 PM
    No, in JSP the variable declaration is not at all thread safe as the declared variables are ended up as instance variable in generated servlet not in body of _jspservice() method.

    The given declaration is not considered to be thread safe: as they are declarations and are evaluated only one time when page gets loaded.

    <%!int a=5;%>

    The given declaration is considered thread safe: as in the scriplets the variables that have been declared are not shared ...
  7. Processes vs Threads

    by , 01-08-2012 at 01:10 PM
    Thread is a single execution in a process as compared to process which is an execution of a program. A process may have multiple threads within it. Also a thread is sometime referred as lightweight process. All the threads in JVM share heap that belongs to the process. In this case, different threads can access same object. Threads always share the heap and contain their own stack to store local variables. In this way threads are kept thread-safe and are synchronized.

    Name:  62.JPG
Views: 4169
Size:  26.7 KB
    ...
    Categories
    Tutorial
  8. Why Tomcat?

    by , 02-24-2012 at 08:36 PM
    In market, various application servers are present. To make a choice b/w them is a tough task. B/w them, Tomcat is one of the best choice. Tomcat offers these features which make it different from other competing solutions.

    • Light and Fast: Tomcat is a highly optimized and light weighted servlet container. While it servers JSPs, everything is outperformed which includes open source based projects like JBoss and Geronimo.
    • Scalable and Flexible - Tomcat is preferred by the developers
    ...
    Tags: why tomcat? Add / Edit Tags
    Categories
    Apache Tomcat
  9. Retrieving Warnings

    by , 03-10-2012 at 09:00 AM
    The SQLWarning objects are subclasses of SQLException. They are involved in dealings with database access warnings. Warning actually doesn’t stop the execution of program, as oppose to exceptions. They inform users that few things which are not present in execution plan are happening.

    E.g:
    • A privilege revoked didn’t revoke.
    • An error occurred, during the requested disconnections.


    A warning might be on:
    • A connection object
    • A ResultSet object
    • A
    ...
    Categories
    JDBC
  10. Categorized SQLExceptions

    by , 03-10-2012 at 09:01 AM
    JDBC driver shall throw SQLException subclass, which presents a common error state or common SQLState. They are not linked to any specified SQLState calss value.

    Portable error handling codes are written by its help.

    These exceptions given are the sub-classes of 1 of the given classes.

    • SQLNonTransientException
    • SQLRecoverableException
    • SQLTransientException
    Categories
    JDBC
  11. Executing PreparedStatement Objects

    by , 03-10-2012 at 09:03 AM
    • Execute statement shall be called for execution of a PreparedStatement Object.
    • The executeQuery when just 1 ResultSet is returned by query,
    • The executeUpdate when no ResultSet is returned by query.
    • The execute when one or more than one ResultSet object return by query.

    Call of “execute update” method is explained by this code.
    Java Code:
    updateSales.setInt(1, e.getValue().intValue());
    updateSales.setString(2, e.getKey());
    updateSales.executeUpdate();
    updateTotal.setInt(1,
    ...
    Categories
    JDBC
  12. Simple Frame Transitions without Complex Code

    by , 03-22-2012 at 08:18 PM
    I've spent the past few days looking up Java window transitions that work with Swing components & containers (JFrame, JPanel, etc.).

    Yes, there are packages such as JavaFX which includes a Timeline & Transition framework. I also came across these:

    Trident:
    Project Kenai &mdash; We're More Than Just a Forge

    FRC:
    Filthy Rich Clients (find the Animation jar (org.jdesktop.animation))

    However, I've been impatient lately ...
  13. Rules for method overriding

    by , 04-26-2012 at 06:56 PM
    • Overridden method and argument list shall exactly be the same
    • Return type shall be the subtype that is being declared in original method that is overridden in superclass, or it shall be the same.
    • Restriction is not more in case of access level as compared to access level of the overridden method. E.g, when superclass is considerd to be public, in that case overriding method present in the subclass would not be public or private. But access level might not be much restrictive ...
    Categories
    Overriding
  14. Class and Method Cheat Sheet

    by , 10-17-2012 at 11:42 PM
    Declaring a Class
    Java Code:
    class ClassName{
      ...code...
    }

    Declaring a Class with Parent
    Java Code:
    class ClassName extends parentClassName{
      ...code...
    }

    Declaring a class with Interface
    Java Code:
    class ClassName implements interface1, interface2, interface3{
       ...code...
    }

    Declaring a Class with Fields
    Java Code:
    class ClassName{
      public
    ...

    Updated 10-18-2012 at 01:30 AM by penguinCoder

    Categories
    Cheat Sheet
  15. ArrayList Cheat Sheet

    by , 10-29-2012 at 12:17 PM
    Importing the Library
    Before you can use an ArrayList, you must first import the necessary library.
    Java Code:
    import java.util.ArrayList
    Creating a Generic ArrayList
    Generic ArrayList is an ArrayList with a type; no other type is allowed to be inserted into the ArrayList.
    Java Code:
    ArrayList<type> listName = new ArrayList<type>();
    Example of this would be:
    Java Code:
    ArrayList<String> myArrayList = new ArrayList<String>();
    ...
  16. How to write a Servlet that sends file to user to download

    by , 12-10-2011 at 05:54 AM
    Downloading files is a very popular task on the World Wide Web. Users click on a download link and the file gets downloaded into their computer. Technically, a download can be achieved by either of the two forms as following:

    • Direct link: the link points directly to a file on a server, for example: http://www.server.com/download/report.xls. This kind of link requires no additional effort on the server side, since the web server automatically hands the file over to users as
    ...
    Categories
    Servlet , File
  17. How to Export JAX-WS EndPoints in Spring

    by , 11-28-2011 at 01:22 AM
    In my previous tip, I showed you how to autowire a JAX-WS endpoint. Although this is very useful, but recognize that the objects whose properties are being injected doesn’t have its lifecycle managed by Spring. There are circumstances though, where it’s possible to export a Spring-managed bean as a JAX-WS endpoint. In this tip, I will show you how.

    Spring’s SimpleJaxWsServiceExporter works by publishing Spring-managed beans as service endpoints in a JAX-WS runtime. SimpleJaxWsServiceExporter ...

    Updated 11-30-2011 at 02:35 PM by Spring Framework

    Categories
    Web , Web Service , Spring 3
  18. Book Recommendations

    by , 06-20-2011 at 10:34 PM
    In this article I plan to create a quick, easy to locate post about good books that I have encountered. Feel free to comment and add your book recommendations. I plan to include more than just Java books in this post. I will start with Java, moving onto c++, and other languages. The end of the post with books I have on my short list. These books will be finished shortly and I will put them here, and update my thoughts as the books are finished.

    Starting out - Which book to get?
    ...
    Categories
    Uncategorized
  19. The Decorator pattern

    by , 07-23-2011 at 03:42 PM (JosAH's blog)
    Greetings,

    the previous blog article talked a bit about the Visitor design pattern. This article talks a bit about additional functionality that is sometimes wanted, i.e. the functionality is optional. Assume there is a lot of optional functionality that people want.

    This article discusses the Decorator (or 'Wrapper') pattern. For the sake of the example we'll use array manipulation. People always fiddle diddle with arrays, i.e. they copy values from one array to another, ...

    Updated 07-23-2011 at 03:45 PM by JosAH

    Categories
    Uncategorized
  20. Using WindowBuilder to design GUI in Eclipse

    by , 02-06-2012 at 04:57 AM
    WindowBuilder is a great Eclipse plug-in that allows developers to visually design graphical user interface (GUI) for Java applications. It supports developing both Swing and SWT applications. In addition, it also supports Google Web Toolkit (GWT) and XML Windowing Toolkit (XWT). This article introduces this plug-in to Java developers about installation and working within Eclipse IDE environment.

    Install WindowBuilder plug-in

    WindowBuilder is already integrated into ...
  21. How to work zip files in Java

    by , 02-29-2012 at 09:59 AM
    he Java platform provides powerful API to work with the most popular compressed file format – zip format. This article will show you how to write code to compress and decompress zip files using Java. And beyond the basics, the code that works with multiple files in a directory recursively is also provided.

    The Zip API

    The package java.util.zip provides classes for working with zip file format. Although the documentation states that the package also provides classes ...
    Tags: file, java, zip Add / Edit Tags
    Categories
    Zip
  22. How to create a Java web service

    by , 04-04-2012 at 06:57 AM
    Web service is a XML-based standard that allows interoperability between different applications on different platforms, for example, a .NET based application on Windows can communicate with a Java based one on Linux. The communication can be done through a set of XML messages over HTTP protocol.

    Throughout this article, you will learn how to create and publish a web service, and consume the web service by a command line client. This article supposes you are familiar with basic Java ...
  23. Reflection example - accessing private data

    by , 05-21-2011 at 06:28 PM (My Java Tips)
    If you think that you cannot access private data members of a class from some other class, then think again. With Reflection, this is possible.

    Using reflection, we can see / view / access a private member, private variable, private method. Some people will not like this with argument that this actually means messing up the laws of encapsulation. I use it for unit testing private methods.

    Example follows:


    Java Code:
    import java.lang.reflect.Field;
    ...
    Tags: reflection Add / Edit Tags
    Categories
    Java SE
  24. Recursion

    by , 06-20-2011 at 05:39 AM
    Recursion:


    Recursion is defined as:
    1. the act or process of returning or running back
    2. logic, maths the application of a function to its own values to generate an infinite sequence of values. The recursion formula or clause of a definition specifies the progression from one term to the next, as given the base clause f (0) = 0, f ( n + 1) = f ( n ) + 3 specifies the successive terms of the sequence f ( n ) = 3 n

    In this article, I hope to make ...

    Updated 06-20-2011 at 05:48 AM by sunde887

    Categories
    Uncategorized
  25. jmap - jdk provided heap observation utility

    by , 06-25-2011 at 02:15 PM
    jmap is one of the lesser known jdk provided utilities, which are worth mentioning. Very oftenly we feel the need to peek into the jvm and see which thread is taking how much of heap space - jmap is jdk’s answer to this.

    This utility was introduced in jdk1.5 and is as an experimental utility (oracle may discontinue to ship this utility with future releases)

    Some of the notable features of jmap are:

    1. can print shared object memory maps or heap memory ...
    Categories
    Uncategorized
  26. Difference Between Comparable And Comparator Interface

    by , 11-08-2011 at 07:29 PM (My Java Tips)
    Programmers are usually confused between "Comparable" and "Comparator" interface. Comparable interface has "compareTo" method which is normally used for natural ordering but Comparator interface has "compare" method which takes two arguments. It can be used where you want to sort objects based of more then one parameter. Following example will make it more clear.




    Java Code:
    package test;/*
     ** Use the Collections.sort to
    ...
  27. Fetching HTML content of a Web Page

    by , 11-10-2011 at 05:46 PM (My Java Tips)
    Sometimes you are required to fetch and store data from web pages. If there are too many pages to parse, then obviously this cannot be done manually. Java provides support for web text extraction.


    The approach is simple. You have to fetch all the HTML contents of a webpage and then you can write your own parser to extract the required info. For example: you might be asked to only store the text in table data tag with caption Hobbies. So you will store all the HTML contents of web ...
  28. Introduction to Spring Web Flow

    by , 11-29-2011 at 03:49 AM
    When you are developing an user interaction for an application, one of the most challenging aspects is to define a proper narrative for the behavior of the application so that the user can get into a flow while using the application. Sometimes it is necessary to step a user through a process, such as ordering a plane ticket. This is called a flowed application. Now is a possible to use any web framework, such as Struts or Java Server Faces, in order to do this. Unfortunately none of them properly ...
  29. AWT vs. Swing

    by , 01-08-2012 at 01:23 PM
    Swing contains a rich set of components as compared to AWT. They are purely build in Java and has following benefits as compared to AWT.

    • Swing contains extra components like JTree, JTable etc.
    • They can change skin based on current look and feel.
    • They follow the MVC design pattern and are more flexible.
    • Swing provided light weight components.
    • Swing provides double buffering.
    • Swing provides paint debugging.

    Swing has following ...
    Tags: awt, swing Add / Edit Tags
    Categories
    Architecture
  30. Advantages of the Drools rule engine

    by , 03-04-2012 at 10:48 AM
    Drools rule engine offers these advantages.
    • It separates conditions and applications

    • They are present in separated files
    • Different people groups can modify them
    • After changing a rule, recompilation is not needed. Redeployment is also not needed in the whole application.
    • To control an application’s flow, put rules at one place
    • All the complexed statements can be replaced by rules in an easier or understandable way

    • Rule language is not tough to be learnt.
    • An
    ...
Page 1 of 4 123 ... LastLast