View RSS Feed

All Blog Entries

  1. Reduce your Spring XML using Java Configuration

    by , 11-27-2011 at 09:47 PM
    As Spring has grown so has the need to configure more and more components leading to the xml configuration files growing larger and larger. In order to address this issue, the Java configuration project was started as a standalone project at SpringSource and developed over the years. It was finally integrated into the core Spring framework in version 3.0. Now you are able to use a powerful ApplicationContext configuration abstraction that has the same level of isolation as its XML cousin. In this ...
  2. Internationalization with Spring

    by , 11-27-2011 at 09:43 PM
    Often it is necessary for an application to be able to support several languages in order to address the requirements of customers located in different countries. For this java has support for what is called internationalization (i18n) that allows allows for an application to resolve text messages for different locales. The means of doing this in Java is to use what is called a ResourceBundle. These are property files that contain a key/message pair and have a special naming convention for the file ...
  3. How to Automatically Discover Spring Beans on the Classpath

    by , 11-27-2011 at 09:38 PM
    Since it’s appearance in Java 5, annotations has helped to simplify the configuration of application through component scanning. This removes the need for XML bean tags in many cases. Classes annotated as component stereotypes including the following: @Service, @Controller, @Configuration, @Component, @Repository as well as the JSR-330 annotations, such as @Named are included in the auto-scan default filter. Once auto-detected, these components become Spring beans and are automatically placed ...
  4. Using Spring Data Access Support with Hibernate

    by , 11-27-2011 at 09:35 PM
    In our previous tip, I gave an introduction to Spring’s persistence technology agnostic approach to data access. In this tip, we will show you how to use Spring with one of the most popular persistence technologies, Hibernate. Hibernate is an open source persistence framework that is one of the most successful persistence frameworks in the developer community. The reason for this is that it is a full featured object relational mapping (ORM) tool. It provides all the features you’d expect from a ...
  5. Netbeans 6.1 New Feature

    by , 11-27-2011 at 05:56 PM (My Java Tips)
    Netbeans 6.1 is available now. There are many new and improved in NetBeans 6.x. In this post, I will list the newly added and improved features.



    Mobility (Java ME)
    source: http://www.netbeans.org/features/javame/index.html
    - Visual Mobile Designer (new)
    - Mobile Game Builder (new)
    - Modular Build System (new)

    Swing GUI Builder
    source: http://www.netbeans.org/features/java/swing.html
    - Beans Binding technology (JSR 295) ...
    Categories
    NetBeans
  6. Writing MIDlet for SMS

    by , 11-27-2011 at 05:53 PM (My Java Tips)
    SMS stands for Short Messaging Service and it is very common in mobile communication. J2ME provides an API for SMS which makes messaging very easy.


    I will write a MIDlet to show how to create a messaging system using javax.wireless.messaging.
    First step is to import all the required APIs:

    Java Code:
    import javax.microedition.midlet.*;
    import javax.microedition.io.*;
    import javax.microedition.lcdui.*;
    import javax.wireless.messaging.*;
    ...
    Tags: api, midletj2me, sms Add / Edit Tags
    Categories
    Java ME
  7. MIDlet Suite

    by , 11-27-2011 at 05:44 PM (My Java Tips)
    In this post, I will introduce you to the MIDlet suite.


    I assume that you people have worked with Eclipse. In Eclipse, you create projects and all the contents of the project are placed in the project folder. It is an approach for managing the work.

    MIDlet suite is very much like a standard Java project in Eclipse. Please note that it's not a requirement to place MIDlets inside a Java Archive (JAR) file, but JAR files provide the most common means of distributing MIDP ...
    Categories
    Java ME
  8. Deploying MIDlets onto Mobile Devices

    by , 11-26-2011 at 06:43 PM (My Java Tips)
    The subject topic is very interesting and a lot of people have asked me about this. It is just a matter of knowing how this works. I am sure you will find it very interesting.


    MIDlets are programmed using Java Development environments like Eclipse, JBuilder,Netbeans or Sun Java wireless Toolkit. Once coded, they are build and tested on emulators. When all the tests are passed, you want to finally deploy it to your mobile device to see how it works in real world scenerio.
    ...
    Categories
    Java ME
  9. EJB - Entity Beans

    by , 11-26-2011 at 06:39 PM (My Java Tips)
    This post contains an introduction to Entity Beans.


    An entity beans are used to represent a business object in a persistent storage mechanism for example: customers, orders, products, employees etc. We normally refer persistent storage mechanism as a relational database. Normally, each entity bean has an underlying table in a relational database. Please note that each instance of the bean corresponds to a row in that table.

    Some people mix Entity beans with session ...
    Categories
    Java EE
  10. Accessing Beans (EJB)

    by , 11-26-2011 at 06:36 PM (My Java Tips)
    In the post, I will write about how to accessing a bean in EJB.


    Accessing deployed beans is simple. First write the the client code and set up JNDI environment settings for the client. It can be done via a JNDI properties file. Now you have to set the class path for the client and add the following file locations to it:

    jboss-client.jar, jnp-client.jar, EJB interfaces, and the directory where the JNDI properties file is stored

    Remember, two JNDI settings ...
    Tags: beans, ejb, jndi Add / Edit Tags
    Categories
    Java EE
  11. JBoss Application Server

    by , 11-26-2011 at 06:35 PM (My Java Tips)
    Talking about J2EE application servers, JBOSS is a popular choice. The reason is that JBOSS is open-source EJB solution with lot of impressive features that are missing in Weblogic, WebSphere, and the other big players.


    Some of the interesting features provided by JBOSS are:

    - enterprise-class security
    - transaction support
    - resource management
    - load balancing
    - clustering
    - database connection pooling
    - JavaMail support ...
    Tags: ejb, jboss Add / Edit Tags
    Categories
    Java EE
  12. Record Management System

    by , 11-22-2011 at 06:14 PM (My Java Tips)
    RMS is a database (flat file) which MIDlets can use to persist data. In this post, I will introduce the audience with RMS.


    The device platform maintains the integrity of the MIDlet's record stores throughout the normal use. The reboots, battery changes, etc. won’t affect the RMS. An interesting question developers ask is, where is this Record Store created? It is created at platformdependent location, like nonvolatile device memory, and is not directly exposed to the MIDlets.
    ...
    Tags: midlet, rms, timestamp Add / Edit Tags
    Categories
    Java ME
  13. TextField vs TextBox

    by , 11-22-2011 at 06:08 PM (My Java Tips)
    javax.microedition.lcdui provides TextField and TextBox which are sometimes confusing. Both are to allow the user to enter text, but question arises, when to use which one? In this post, I will try to address this issue.


    Let me first explain TextField (javax.microedition.lcdui.TextField). This class inherits from javax.microedition.lcdui.Item, so you should know that its an item that can be placed on a form. To create an instance of TextField, we use the TextField constructor: ...
    Categories
    Java ME
  14. Maven (intro)

    by , 11-22-2011 at 06:02 PM (My Java Tips)
    Maven is a software project management tool, based on project object model. It aims at reducing the load of developer by making in software build process simple and faster.


    Following are worth mentioning features of Maven:

    - Provides a uniform build system
    - Provides quality project information
    - Provides guidelines for best practices development
    - Allows transparent migration to new features

    When to use Maven is an interesting question. ...
  15. XML Pull Parsing (Demo)

    by , 11-22-2011 at 05:58 PM (My Java Tips)
    XML Pull Parsing makes parsing XML documents easier and efficient. This post introduces this API.


    You may get the required API from http://www.xmlpull.org/.
    Java docs are available at: http://www.xmlpull.org/v1/doc/api/or...ullParser.html

    Let me present an example of parsing XML using XML Pull Parsing.




    Java Code:
    public class SimpleXmlPullApp
     {
    
         public static void main (String args[])
    ...
    Categories
    XML
  16. Jsr 75

    by , 11-22-2011 at 05:52 PM (My Java Tips)
    JSR 75 specifies 2 optional packages for mobile devices. I will be talking about these in the next few posts.


    The two provided packages are:
    Java Code:
    javax.microedition.io.file
    javax.microedition.pim
    PIM stands for personal information and it contains following information:
    - contact list
    - todo list
    - events

    If you want to access these from a J2ME application, then javax.microedition.pim is to be used.

    ...
    Tags: j2me, jsr 75, pim Add / Edit Tags
    Categories
    Java ME
  17. Subversion (intro)

    by , 11-22-2011 at 05:45 PM (My Java Tips)
    Subversion is a centralized system for sharing information. It comprises of a repository, which is a central store of data. The repository stores information in the form of a file system. Clients can connect to this repository, and can read or write to these files. When a client writes data, it actually makes the information available to others; and when a client reads the data, it actually receives information from others. Its a typical client server system which uses version model.

    ...
  18. Subclipse

    by , 11-22-2011 at 05:41 PM (My Java Tips)
    Consider that you are working on a large/medium size Java project in teams. This is an ideal scenario for using Subversion to distribute and maintain source code. Good news is that you can use integrate your source code with Subversion within Eclipse environment.


    An Eclipse plugin called Subclipse is to be used for integrating source code with Subversion within Eclipse environment. You may download Subclipse from:
    http://subclipse.tigris.org/download.html

    Once ...
    Categories
    Subversion
  19. Reading/writing files

    by , 11-22-2011 at 05:26 PM (My Java Tips)
    This post is all about reading and writing text files on mobile device.


    In order to write files on the mobile device, you need com.motorola.file.writeaccess. If your application has that permission, you can write files easily using the following code.

    Java Code:
    FileConnection sc = (FileConnection)Connector.open("file:///phone/tmp.txt");
    OutputStream os = sc.openOutputStream();
    os.write(("text to go into the file").getBytes());
    ...
  20. Sending SMS (snippet)

    by , 11-22-2011 at 05:22 PM (My Java Tips)
    This post presents a snippet for sending short text messages from J2Me applications.


    The com.sun.midp.io.j2me.sms package provides an API for the Short Message Service Messaging system and allows MIDlet to access SMS functionality on a GSM mobile device. You need javax.wireless.messaging.sms.send premission to send SMS messages from your J2ME application. The sample code is presented below:

    Java Code:
    sender = (MessageConnection)Connector.open("sms://");
    ...
  21. GPS location / Cell id / Placing a call

    by , 11-22-2011 at 05:16 PM (My Java Tips)
    This post presents miscellaneous tasks that you can do in your J2ME application.


    Firstly, how to get GPS location. javax.microedition.location.Location provides support for this. Review the snippet below:

    Java Code:
    LocationProvider loc = LocationProvider.getInstance(null);
    loc.setLocationListener(ll,0,-1,-1);
    Location location = loc.getLocation(60*3);
    String lat = location.getQualifiedCoordinates().getLatitude();
    String lon = location.getQualifiedCoordinates().getLongitude();
    ...
  22. MIDP packages

    by , 11-22-2011 at 04:53 PM (My Java Tips)
    MIDP provides a standard run-time environment that allows new applications and services to be deployed dynamically on end-user devices like cellular phones and pagers. The MIDP is built upon CLDC (Connected Limited Device Configuration).


    MIDP is an industry-standard profile for mobile devices and it is not dependent on a specific vendor. It is a provides foundation for mobile application development. MIDP contains following 3 core CLDC packages:

    java.lang
    java.io ...
  23. Ant Paths

    by , 11-21-2011 at 05:05 PM (My Java Tips)
    If you specify the PATH and the CLASSPATH type references using any of this, that is ":" and ";" as a separator characters, Ant can convert the separator to the correct character of the operating system in the use.


    A nested element can be used wherever path like values need to be specified. See the example below.
    Java Code:
        <classpath>
    <pathelement path="${classpath}"></pathelement>
    <pathelement location="lib/helper.jar"></pathelement>
    ...
    Categories
    Ant
  24. Package Explorer - Class Method

    by , 11-21-2011 at 05:01 PM (My Java Tips)
    In this post, I will write about Eclipse feature that shows the artifacts of a class method.


    Eclipse package explorer is a very useful explorer that gives the developer a birds eye view of the package, class and methods. Review the class below:

    Java Code:
    public class Student {
    
    	private int id;
    	private String name;
    	private static int counter;
    	private static final int MAXCOUNT=10;
    
    	public Student(int id, String name)
    ...
  25. Object references

    by , 11-21-2011 at 04:58 PM (My Java Tips)
    In this post, I will be talking about how to refer to an object. I will present a simple example to make things obvious.


    We have a class called Student. It had 2 attributes, getter setter methods and a method named showAll() to show the contents of both the attributes.

    Java Code:
    public class Student {
    
    	private int id;
    	private String name;
    
    	public Student(int id, String name) {
    		this.id = id;
    		this.name = name;
    ...
  26. Method signatures

    by , 11-21-2011 at 04:52 PM (My Java Tips)
    In this post, I will present an interesting example related to method signature.


    Method signature comprise of the following:

    - method name
    - return type
    - input parameters
    - access modifier

    For example:

    Java Code:
    public Vector processText(String test, int id)
    Two methods in a class can have same name provided then have different parameters. Different parameters means different no of parameters and ...
  27. Using static and final attributes – An example

    by , 11-21-2011 at 04:47 PM (My Java Tips)
    In this post, I will present an example which used static and final keywords with attributes in meaningful way. I hope after going through this, you will develop good understanding of these.


    As may know, that we may access static member of class without using any object of that class. Final field/attribute means that you cannot change its value. If you try to change the value of final attribute, you will get an error – some this like this:


    Exception in thread ...
  28. Java Data Object (basics)

    by , 11-21-2011 at 04:42 PM (My Java Tips)
    Java Data Object (JDO) can be used to build an application that creates, reads, updates, and deletes persistent instances of Java classes. These objects can be persisted on to relation database, object oriented database or on to XML files. This depends on the implementation of JDO you are using.

    One needs to get the basics before starting working with JDO. Once you have the basics, you can map java objects to the data source transparently.

    JDO allows you to map your ...
    Categories
    JDO
  29. JDO – Byte Code Enhancement

    by , 11-21-2011 at 04:39 PM (My Java Tips)
    In order to store instances of a class into data store, a class has to be persistence capable. There are different ways to make a class persistence capable. One of the way is Byte Code Enhancement.


    When a Java class is compiled, a class file is generated. It contains the byte code. To make a class persistence capable, some extra code will surely be added to our source. In order to make the process transparent, byte code modification can be done. So this works even, if you don’t have ...
  30. @SuppressWarnings annotation

    by , 11-21-2011 at 04:34 PM (My Java Tips)
    In this post, I will be talking briefly about SuppressWarnings annotation.


    Java compiler gives you warnings to assure that you know what is happening. Sometimes, you want don’t want the warnings. Java 5.0 provides a way for this.

    One had to use SuppressWarnings annotation to ignore the warnings. Annotations are followed by @.

    For example: consider the following code:
    Java Code:
    int a;
    Object object = new Object();
    I declared two variables ...
Page 33 of 48 FirstFirst ... 23313233343543 ... LastLast