View RSS Feed

All Blog Entries

  1. Subclipse - changing user credentials

    by , 11-07-2011 at 05:11 PM (My Java Tips)
    Subclipse is a very popular Eclipse plugin which provides SVN repository supports within Eclipse. It serves the purpose but there is no real way to change the SVN user for a repository if credentials are saved. I will try to address this problem in this post.

    First of all, why you would need to change the svn user credentials? Person A is working on your machine and he checks out a project from a SVN repository using his credentials. He saves his SVN credentials in your Eclipse environment. ...
  2. Linking files with Editor

    by , 11-07-2011 at 04:50 PM (My Java Tips)
    There is a very useful Eclipse feature that is normally not used by the developers. Its called ‘Link with Editor’. I'll write about it.

    In complex projects, lot of files are involved. To search a rile, you may use Open Resource window – which is really very useful. Then you may click the file and can see/modify the contents. You might want to see where the file lies in the project. Obviously lots of folders are involved and its not easy to manually search for the file. You can simple ...

    Updated 11-07-2011 at 05:09 PM by Java Tip

  3. 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 ...
    Java ME
  4. PIM - ToDo

    by , 11-06-2011 at 06:04 PM (My Java Tips)
    javax.microedition.pim.ToDo is an interface that extends from PIMItem. It represents a single ToDo item in a PIMToDo database. I will present an example of how to retrieve ToDo list from PIM.

    Consider the following example. We create todos with fields of our interest. But before adding the field,w e should check if its supported on the platform or not.

    Java Code:
    ToDoList todos = null;
     try {
        todos = (ToDoList) PIM.getInstance().openPIMList(PIM.TODO_LIST,
    Java ME
  5. Error codes lookup

    by , 11-06-2011 at 06:02 PM (My Java Tips)
    There are sometimes situations, when you need some look up mechanism. I will present few example in the next few posts.

    Let me present an scenario. We have an application which reads and writes to files on a file system. We have defined a error generating and tracking mechanism as well. Each error is assigned an error code and that code is thrown in case an error is encountered. To Interpret the code, we need to have some lookup mechanism.

    I defined a final class with ...
    Java SE
  6. Benefits of using Final class

    by , 11-06-2011 at 05:58 PM (My Java Tips)
    Final classes have a lot of benefits if used where required. I will present benefits of final classes in this post.

    Sometimes, you wish that no one can inherit from your class since its functionality is completed and should not be inherited. In that case, you may define your class as final, and then no class can inherit from it. The method of final class are also final. Final methods cannot be overridden in any sub class. There is also performance issues related to final class. A ...
    Java SE
  7. Final variables

    by , 11-06-2011 at 05:57 PM (My Java Tips)
    A final variables in Java are can only be assigned once. Once they are assigned some value, they cannot be assigned some other value.

    If you have final class variable, they must be assigned to in the constructor of the class. An interesting thing is that the value of a final variable is not necessarily known at compile time. Consider the following example:

    Java Code:
    public class Sphere {
        public static final double PI = 3.141592653589793;
    Java SE
  8. Using a custom task in Ant

    by , 11-06-2011 at 05:53 PM (My Java Tips)
    It is assumed that you have already defined a custom Ant task and wish to use it. In this post, I will show you how to do so.

    You first need to define the task by giving it a name and telling Ant the classfile that implements it and any classpath setting required to locate that classfile. This is done using the taskdef task, like so:

    <taskdef name="fileparser">classname="FileParser"
    classpath="."/&gt; ...
    XML , Ant
  9. Defining custom tasks in ANT

    by , 11-06-2011 at 05:49 PM (My Java Tips)
    Ant provides various core and optional tasks which you use to automate the build process. Very seldom, you need to define your own customized tasks.

    To implement a simple custom task, you need to extend the class and override the execute() method. Follow the sample below:

    Java Code:
    public class FileSorter extends Task {
    // The method executing the
  10. JBossWS

    by , 11-06-2011 at 05:47 PM (My Java Tips)
    JBoss used to have JBoss.NET package for web services. Now, there exists JBossWS module which is responsible for providing web services in JBoss 4.0.

    It is based on Apache Axis like JBoss.NET but the difference is that JBossWS provides the complete set of J2EE 1.4 web services technologies like SOAP, SAAJ, JAX-RPC and JAXR. The J2EE web services support exposing EJBs as web services, but only stateless session beans can be used.

    JBossWS is a JAX-WS compliant web service ...
  11. JBoss directory structure

    by , 11-06-2011 at 05:45 PM (My Java Tips)
    You should be knowing the directory structure of JBoss server, in order to work efficiently with JBoss. I will target the directory structure in this post.

    The jboss-4.0.2 directory contains following sub-directories:

    Contains startup and shutdown scripts.

    Client folder contains configuration and JAR files that are required by Java client application or an external web container.

    The XML DTDs used in ...
  12. SVN (Trunk/Branch/Tag)

    by , 11-06-2011 at 05:41 PM (My Java Tips)
    SVN (SubVersion) is being used in software development houses to maintain the source code. Its very effective if used properly. In this post, I will present some basic concepts about SVN.

    Usually, SVN has following directory structure:


    You may add more directories like archive and some other of you want. I will explain the use of above directories so you know when to use what.

    The trunk directory contains ...
  13. Writing System Properties

    by , 11-06-2011 at 05:35 PM (My Java Tips)
    System's setProperties() method can be used to modify existing system's property. It takes a Properties object that has been initialized to contain the key/value pairs for the properties that you want to set.

    This method actually replaces the entire set of system properties with the new set Properties object. Lets review an example that creates a Properties object,initializes it from a file and then uses System.setProperties() to install the new Properties objects ...
    Java SE
  14. Environment Variables

    by , 11-06-2011 at 05:31 PM (My Java Tips)
    Environment variables are used by operating systems to pass useful information (configurations) to the applications. Environment variables are key/value pairs very much like properties. The key and the value, both are strings. To set environment variables, please read system documentation as it varies from one operating system to another.

    In our Java applications, we use System.getEnv to retrieve environment variable values. If no argument is passed, getEnv will return ...
    Java SE
  15. Java built-in data types (performance issues)

    by , 11-06-2011 at 05:29 PM (My Java Tips)
    Java built in data types provide programmers ease of storing their required data in appropriate data type. But in come cases, it may become a bottleneck. When doing low level related work, the speed is very important. In such case don't use the Java built-in data types.

    Lets take an example. If you are using an Integer class, just think of all the overhead you are creating by using the wrapper class. One rule of thumb is to use the primitives instead of wrapper. This ...
  16. JBoss – Web Container

    by , 11-06-2011 at 05:27 PM (My Java Tips)
    I assume you are familiar with Tomcat. Normally developers start learning J2EE with Servlet and JSP and deploy them on Tomcat. JBoss now comes with Tomcat 5.5 and is used as default web container.

    The embedded Tomcat service is the expanded SAR jbossweb-tomcat55.sar in the deploy directory. All the required JARs also exist there. The file web.xml provides default configuration set for web applications. server.xml, which contains standard Tomcat format configuration information. This ...
  17. Preparing development environment for J2EE dev/JBoss

    by , 11-06-2011 at 05:25 PM (My Java Tips)
    I will show how to prepare development environment for J2EE development using JBoss. Download and install the JBoss. I will be using jboss-4.2.2.GA. Now download the latest Java EE Eclipse from I have version 3.3.2.

    You should have all the required plugins for J2EE development with JBoss in your Eclipse. Navigate to:

    Help > Software updates > Find and Install > Search for new features to install > New remote site

    You can name ...
    JBoss , JSF , Eclipse , EJB , Java EE
  18. Jboss-4.0.2 hibernate bug

    by , 11-06-2011 at 05:21 PM (My Java Tips)
    Hibernate is a popular persistence engine that runs in almost any application server and provides alternative of standard entity beans. With JBoss, you can choose to deploy your application as a Hibernate archive, called a HAR file. This makes using hibernate simpler. JBoss is responsible for managing hibernate session and other configuration details.

    Jboss-4.0.2 does not include Hibernate3 integration module. This requires Apache commons collections JAR. To fix this, use fix-hibernate ...
    Hibernate , Java EE , JBoss
  19. Creating a Hibernate archive

    by , 11-06-2011 at 05:20 PM (My Java Tips)
    Consider a simple POJO with no direct coupling to Hibernate. The details of the Hibernate mapping will be specified in the Player.hbm.xml file.

    Player.hbm.xml is shown below.

    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    <class name="org.jboss.roster.Player" table="PlayerBean">
    <id ...
    Hibernate , XML
  20. Using the hibernate objects

    by , 11-06-2011 at 05:18 PM (My Java Tips)
    I assume that you know how to create hibernate archive and you have created a fully configured SessionFactory for use in other parts of your application. I will present an simple JSP which creates a Session from the SessionFactory and issues a query directly.

    It’s a good practice to put the Hibernate access code in a servlet or in a
    session bean, but for example purposes I will use JSP.

    The example shows how to access Hibernate session in the ...
  21. jboss-service.xml

    by , 11-06-2011 at 05:16 PM (My Java Tips)
    JBoss core services are listed in conf/jboss-service.xml file. These services are started first when the server starts up. You may open the file in any test editor or in some XML editor. You will see MBeans for various services including logging, security, JNDI. You may comment any service for example:

    Now if you restart JBoss, you wont see the JNDIView service in the management console listing. In normal practice, you very seldom needs to alter this file. Remember that the ...
    JBoss , Java EE
  22. JBoss - Logging Service

    by , 11-06-2011 at 05:13 PM (My Java Tips)
    Jboss uses Apache logging application called log4j for logging. You can find log4j.jar under lib director. The logging service is enabled from jboss.service.xml.

    The file will read like this:

    <!-- ================================================== ================== -->
    <!-- Log4j Initialization -->
    <!-- ================================================== ================== --> ...
    JBoss , XML
  23. Using Maven - Unit Tests

    by , 11-05-2011 at 07:00 PM (My Java Tips)
    You want Maven to compile your unit tests. Simply place you unit tests in a directory and mention the director under


    Once that is done, specify the unit tests which you want to run in unitTest XML element. You may use includes and excludes tags to include or exclude the classes.

    Java Code:
  24. Documenting projects

    by , 11-05-2011 at 06:58 PM (My Java Tips)
    Everyone know how important it is to document the project. I wont be shedding light on this. But the aim of this post is
    to introduce how Maven can help you generate project documentation.

    Maven can actually generate a website for your project. Use following command to generate documentation:
    Run the site:generate goal for your project with this command:

    maven site:generate

    Maven will generate html documentation in the docs ...
  25. JMS - Publish-Subscribe Messaging

    by , 11-05-2011 at 06:55 PM (My Java Tips)
    Programs can create, send and read messages in distributed enterprise environment using MOM (Message-Oriented-Middleware). The Java Message Service (JMS) provides a standard Java-based interface to the message services of a MOM of some other provider.

    There are few messaging models available which determine which client receives the message.
    Publish-Subscribe Messaging
    Point-To-Point Messaging
    Request-Reply Messaging

    Lets first talk ...
  26. JMS - Request – Reply Model

    by , 11-05-2011 at 06:51 PM (My Java Tips)
    This model is used when real time response is required. JMS provides two API to implement Request – Reply model which are QueueRequester and TopicRequester.

    You may use this is you wish to use QUEUE. It creates a TemporaryQueue for the responses and provides a request() method that sends the request message and waits for its reply.

    This API uses TOPIC to get responses. It creates a TemporaryTopic for the responses ...
  27. Entity (Tips/Info)

    by , 11-05-2011 at 06:47 PM (My Java Tips)
    In this post, I will present some useful information about Entities. I hope these will prove useful.

    You may indicate the entity class by annotating it with the Entity annotation or you may denote that class as entity in the XML descriptor. The entity class must have no-arg constructor and it should either be public and protected. The entity class can have other constructors as well.

    Another important thing to note about entity class is that the entity ...
  28. Sample Entity Bean

    by , 11-05-2011 at 06:45 PM (My Java Tips)
    Creating entity bean is simple. You have to annotate the class to indicate that it’s an entity bean. Also your class should implement Serializable interface. An example entity bean is presented below. Do note that we have defined a no argument constructor which is a must.

    Java Code:
    public class Customer implements Serializable {
    private Long id;
    private String name;
    private Address address;
    private Collection
  29. Managing dependencies using Maven

    by , 11-05-2011 at 06:42 PM (My Java Tips)
    Maven can manage all jar file dependencies for the build machines. Let me explain how to do this.

    We use dependency element to refer to a jar file which reside in a remote repository. It is said that in near future, the dependencies will extend beyond jar files. Maven places the jar files (fetched from remote repository) on the local repository. The element has three child elements, , , and . Maven looks in the remote repository for a directory with the same name as ...
    Maven , XML
  30. Debugging Remote Java Application

    by , 11-05-2011 at 06:38 PM (My Java Tips)
    Debugging is very helpful is following the flow of an application and knowing what happens when. You get list of variables with their values and you can flow what exactly is happening. It really helps is identifying the problem areas. Debugging in Eclipse is really simple and easy. I assume that you have done debugging in Eclipse.

    Debugging a J2EE application is a bit tricky since the application is deployed in web/application container. JBoss provides support for ...
    Eclipse , Java EE , JBoss
Page 11 of 17 FirstFirst ... 910111213 ... LastLast