Category «Java»

New features coming to Java 7

Joseph Darcy, the lead of Project Coin, formally announced the approved changes to the Java language to be included in JDK 7.  Although there was no major change announced, the announced enhancements will improve program readability. Following are few changes that I am glad they are going to incorporate in JDK7.

How to remove (delete) Eclipse workspace from the dropdown list.

Eclipse is my favorite Java IDE. To manage projects Eclipse uses ‘Workspaces’. Workspace is basically a folder on your disk where your project files are stored. To work on a project you load its workspace in Eclipse. Eclipse remembers the workspaces you worked on previously. A drop down list of all (configurable) previous workspaces is …

Ultimate Java Regular Expression to validate any email address.

My post about Java regular expression gets a lot of hits daily. Someone commented that the regular expression I included in that post does not block certain invalid email addresses. So I updated the Java regular expression to validate email address. I am pretty sure that the following Java regular expression will validate any email …

How to read properties file in Spring.

If you need to read properties file in your Spring application all you need is to configure a PropertyPlaceholderConfigurer bean in your application context. Following example shows how to read property values from a properties file named config.properties. This file needs to be in your classpath so Spring can find it. Let’s begin by creating …

How to configure multiple handlers in a Spring MVC web application

In Spring MVC, DispatcherServlet relies on handler mapping to determine which controller the request should be sent to. All handler mapping classes in Spring implement org.springframework.web.servlet.HandlerMapping interface. Spring distribution contains following four implementation of HandlerMapping interface. BeanNameUrlHandlerMapping SimpleUrlHandlerMapping ControllerClassNameHandlerMappign CommonsPathMapHandlerMapping BeanNameUrlHandlerMapping is the simplest of all and DispatcherServlet looks for this mapping by default. You …

How to add external jar files to Maven project POM

Maven has made compiling Java projects almost an effortless job. You no longer need to worry about placing all the required class files in your classpath. All you have to do is to include dependencies in your POM file and Maven takes care of the rest. It automatically downloads the jar file that your project …

Import static elements for more readable Java code

One of the welcome additions to Java language in Java 5 release is the static import declaration. static import works in the same way as traditional import declaration but it imports only the static members of a class. Traditional import declaration looks like this import java.util.*; The above statement will import all the classes under …

Test your Java skills.

Even with many years of experience with programming in Java one cannot claim that he or she has mastered the language. What I found out with experience is that unless your job offers you diverse problems to solve, you are more likely to work on similar projects and hence may end up using the exact …