View RSS Feed

Most Popular Blogs

  1. Java ArrayList : Generics & Sorting

    by , 07-21-2011 at 06: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 06: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 06: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. Using Spring Web Flow Part 1

    by , 11-30-2011 at 04: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, ...
  5. Processes vs Threads

    by , 01-08-2012 at 12: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: 1290
Size:  26.7 KB
    ...
    Categories
    Tutorial
  6. How to get e-mail with Java

    by , 02-29-2012 at 03:39 PM
    In the article “How to send e-mail with Java”, you are familiar with the JavaMail API on sending e-mail messages from a SMTP server. What about receiving e-mail messages? Well, that is the topic of this article. We will study how the JavaMail API exposes classes and interfaces for retrieving e-mail messages from a server, to write a utility class that checks for new messages in inbox of an e-mail account from Gmail server.

    Protocols for receiving e-mail

    There are two ...
    Categories
    Mail API
  7. Retrieving Warnings

    by , 03-10-2012 at 08: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
  8. Categorized SQLExceptions

    by , 03-10-2012 at 08: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
  9. Executing PreparedStatement Objects

    by , 03-10-2012 at 08: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
  10. ArrayList Cheat Sheet

    by , 10-29-2012 at 11:17 AM
    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>();
    ...
  11. How to write a Servlet that sends file to user to download

    by , 12-10-2011 at 04: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
  12. Book Recommendations

    by , 06-20-2011 at 09: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
  13. The Decorator pattern

    by , 07-23-2011 at 02: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 02:45 PM by JosAH

    Categories
    Uncategorized
  14. How to create a Java web service

    by , 04-04-2012 at 05: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 ...
  15. Reflection example - accessing private data

    by , 05-21-2011 at 05: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
  16. Recursion

    by , 06-20-2011 at 04: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 04:48 AM by sunde887

    Categories
    Uncategorized
  17. jmap - jdk provided heap observation utility

    by , 06-25-2011 at 01: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
  18. Difference Between Comparable And Comparator Interface

    by , 11-08-2011 at 06: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
    ...
  19. How to Export JAX-WS EndPoints in Spring

    by , 11-28-2011 at 12: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 01:35 PM by Spring Framework

    Categories
    Web , Web Service , Spring 3
  20. AWT vs. Swing

    by , 01-08-2012 at 12: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
  21. How to work zip files in Java

    by , 02-29-2012 at 08: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. JMeter Listeners

    by , 04-27-2012 at 07:26 PM
    Listeners provide access to the information JMeter gathers about the test cases while JMeter runs. The Graph Results listener plots the response times on a graph. The "View Results Tree" Listener shows details of sampler requests and responses, and can display basic HTML and XML representations of the response. Other listeners provide summary or aggregation information.

    Additionally, listeners can direct the data to a file for later use. Every listener in JMeter provides ...
    Categories
    Tutorial
  23. The Five Tiers in Java EE

    by , 11-19-2011 at 05:57 PM (My Java Tips)
    This post briefly explains the 5 tiers in Java Enterprise Edition.



    Client

    A web browser, a hand held device or an application which remotely accesses the services of an enterprise application are examples of a Client tier. In other words a Client tier can consists of all the types of components that are clients of an enterprise application.

    Presentation

    Filters, Java Servlets, JavaServer Pages, JavaBeans and other utility classes ...
  24. Building your first Struts 2 application using Eclipse

    by , 12-09-2011 at 04:30 PM
    Struts is one of the most popular web framework for Java. It comes with 2 major branches, Struts 1 and Struts 2. Both implement MVC architecture but Struts 2 is much simpler, easier to build, deploy and maintain than Struts 1.
    This article will guide you through the steps to build a simple Struts 2 application using Eclipse IDE.

    Download Struts 2 and required libraries

    Download latest version of Struts 2 from Download a Release
    Select the full distribution, ...
    Categories
    Eclipse , Struts
  25. Passing parameters in RMI

    by
    RMI
    , 01-02-2012 at 06:36 PM
    • By value, primitive types get passed. For example, Boolean, char, int etc.
    • Being remote references, remote object references get passed which permits the client process to make the methods invoked.
    • By object serialization, non remote objects get passed by value. Implementation of the java.io.Serializable interface shall take place which shall allow objects to get serialized.

    Remote method’s invocation gets initiated by the client process, using calling method present ...
    Categories
    Tutorial
  26. Minimize memory leaks in Java

    by , 01-08-2012 at 12:46 PM
    The main causes for memory leaks in java are poor design with invalid references. Garbage collector is not able to claim those objects.

    Following steps help you to detect memory leaks in your application.

    • Use tools like JProbe, OptimizeIt.
    • Use operating system process monitors.
    • Override totalMemory() and freeMemory() methods in the Java Runtime class.

    Following steps help you to minimize memory leaks in your application.
    ...
    Categories
    Memory
  27. A recursive method for searching an array of integers...

    by , 03-08-2012 at 08:49 PM
    Java Code:
    public class ArrayLister {
    	
    	private static int arraySearcher(int[] arrayToSort,int numberToFind,int left,int right){
    		
    		int middle = (left + right) / 2 ;
    		System.out.println(middle);
    
    		if(middle==arrayToSort.length-1)
    		{
    			if(arrayToSort[middle] == numberToFind) {
    				return middle;
    			}
    			else
    				return -1;
    		}
    		
    		if(arrayToSort[middle] == numberToFind) {
    			return
    ...
    Categories
    Uncategorized
  28. Building your first Spring 3 MVC application using Eclipse

    by , 12-10-2011 at 06:51 AM
    Spring is one of the most popular application frameworks for Java development. The framework comes with various projects like Spring Core, Spring Data, Spring Web Services, Spring MVC…Each project suits for a particular area, and for the area of web development, Spring MVC is very well-known.
    Spring MVC makes web development easier by separating the three components: Model, View, and Controller.

    • The model represents the principal data that is managed by the application.
    ...
    Tags: eclipse, mvc, spring 3 Add / Edit Tags
    Categories
    MVC , Spring 3 , Eclipse
  29. The Singleton pattern

    by , 08-12-2011 at 04:29 AM
    In mathematics a singleton (not to be confused with a simpleton) is a set with exactly one element.
    In computer science Singleton is a pattern which enforces the existence of only up to one instance of a class.

    Singleton is sometimes considered an anti-pattern, and it's famous for being considered unnecessary in the world of Python (where you duck type).
    Singleton is however useful, it is a nice and clean why to restrict the number of instances, to only one.
    In ...

    Updated 08-12-2011 at 06:13 PM by Hibernate (typo)

    Categories
    Patterns
  30. What is a remote object? Why UnicastRemoteObject should be extended?

    by
    RMI
    , 01-02-2012 at 06:34 PM
    Remote object is considered to be the one in which other JVM are used to invoke the methods. Remote interface gets implemented by the remote object class. RMI is that application that produces various remote objects.
    Responsibility of a RMI Server is:
    • To create the remote object’s instance e.g CarImpl instance = new CarImpl()).
    • Export the remote object.
    • Bind the remote object instance to the RMI registry.

    Client’s incoming calls are being accepted ...
    Categories
    Tutorial
Page 1 of 3 123 LastLast