Wednesday, February 7, 2018

Start Your Spring development with IntelliJ IDEA in 3 Minutes

Lots of my students and juniors keep telling me that, setting up a “Spring” development environment is a big hassle. There are many tutorials are available in the web but they are not comfortable with those. May be the tools we are using are slightly different with them or it is just a time consuming for the initial setting up. That is why I choose to write a post them to start a spring project from scratch, hopefully it will help others too. I am using “IntelliJ IDEA” ultimate IDE (as usual) and maven for build automation tool. I will deploy it on JBoss server (similar on Apache Tomcat or Oracle WebLogic).
You will find lots of good tutorials on downloading and setting up IDE (Idea) and web-server (JBoss) and the basic knowledge on Spring MVC, so I am omitting those things (if you don’t find it on Google, make a comments on the below comment section).

    Please follow steps by steps –
1)    Go to  New Project -> Maven , don’t select archetype and press Next

2)    Write GroupId, ArtifactId, Version like this.

groupId will identify your project uniquely across all projects, so we need to enforce a naming schema. It has to follow the package name rules, what means that has to be at least as a domain name you control, and you can create as many subgroups as you want. Example-

artifactId is the name of the jar without version. If you created it then you can choose whatever name you want with lowercase letters and no strange symbols. If it's a third party jar you have to take the name of the jar as it's distributed. Example-

version if you distribute it then you can choose any typical version with numbers and dots (1.0, 1.1, 1.0.1, ...). In this example, we will keep the default-

3)    Press Next then write the Project Name and select the project location, then click Finish  

4)    Open the maven pom.xml file (if not opened yet automatically) and add the following lines inside the project tag.-





You can choose enable auto import option or you have to click import changes whenever you have made any change on the pom.xml

5)    Create webapp and WEB-INF directory in the main folder as shown below –

6)    Create web.xml file in WEB-INF and write the following lines-

<?xml version="1.0" encoding="ISO-8859-1" ?>

<web-app id="WebApp_ID" version="2.4"

    <display-name>Spring Test Application</display-name>
        This is a simple spring mvc app




7)    Now create dispatcher-servlet.xml file on WEB-INF directory and add the following lines on it

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
    <context:component-scan base-package="com.roni.springtest.controllers"/>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/"/>
        <property name="suffix" value=".jsp"/>

Here base-package is your java package, which we will going to create on the next steps.

8)    Now create the package and a new Controller class SpringTestController in it. Write the following codes –

package com.roni.springtest.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

 * User: Towhidul Haque Roni
 * Date: 2/7/2018
 * Time: 2:39 PM
public class SpringTestController {

    public String index(Model m) {
        m.addAttribute("aVariable", "Hello World");
        return "index";

9)    Create directory views in WEB-INF and create index.jsp file on it. Write the following lines on it-
<!DOCTYPE html>

    <h1>Spring MVC Test</h1>



10)    Now if you click Run from Run menu for the first time, you will be prompt to Edit Configuration. If you click, following menu will  appear –

11)    Click the top most left + sing, then scroll down and you will see the JBoss Server. Select the local, If you have already configured the JBoss server it will appear in the application server dropdown list, if not then click Configure and it will require to show the JBoss home directory. I have downloaded the jboss-eap-7.1.0 and unzip it and showed the path ( jboss-eap-7.1.0\jboss-eap-7.1 ) as a home directory.

12)    Then go to Deployment , click the right most + sign and add springtest.war artifacts like below  -

13)    Now click Run, hopefully you will be able to see the output like below –

Enjoy!!! I hope that it will save your time. On the upcoming post, I will do REST web service and spring data within 5 minutes setting up time.

Friday, March 27, 2015

How to Run Glassfish 3 on JDK8 /JRE8


Have you updated your PC with new Java 8? Are you using glassfish3 because of unstable glassfish 4 or support or any other reason? Now you will face problem as there is no option to run the glassfish 3 on JRE8. If you have earlier JDK too,  you will get  the error of  'Unsupported major.minor version' during the deployment of app with new jar (compiled with newt JDK ). Here is a little trick I have done to do so –
        1) Open the file ‘domain.xml’ located at

Edit the ‘java-home’ for example replace –
java-home="C:\Program Files\Java\jdk1.6.0_45"
java-home="C:\Program Files\Java\jdk1.8.0_40"

        2) Then open the file ‘’ located at

Append the following line at the end –
        3) Done… run and enjoy :)
You can check your Glassfish’s JDK from- 

Monday, September 10, 2012

Intellij Idea key scheme for Eclipse

I’m a diehard fan of intellij idea. I also developed few android apps on idea. Just missing the UI drag and drop option but it will come in the version 12.  Already preview option is available from version 11. There are some projects on going in my office and I have to use eclipse, so I have to know the shortcut of eclipse. But suddenly I found an idea key scheme for eclipse.  Download the latest jar from the following URL –
Then put the jar on “plugins” directory of the eclipse and restart the eclipse IDE.
Now you will see idea schema on Keys (Window->Preferences->General->Keys).
Thanks to Santhosh to make our life easy :)

Sunday, May 8, 2011

Making jar by IntelliJ IDEA

Few people told me why are you using idea, it is not possible to create jar from it. Actually this idea about idea is totally wrong. To make a jar from idea go to

File -> Project Structure -> Artifacts

Then click the plus sign to add a jar setting. The “Create Jar from Modules” window will appear. Select the module and main class.

1) Choose extract to the target jar to include all the library jars include in your jar. Then press Apply and Ok. After than you will see a “Build ‘moduleName.jar:’ artifact” option in Build menu. It’s simple.


2) And if you choose “copy to output directory and link via manifest” the edit the manifest to locate the library jars in Class-Path tag ex-(lib/one.jar lib/two.jar). Remind that if you execute the jar from a folder which folder is located in the project root directory and your library jars are located on a “lib” folder which is also in the root project directory, then add class path like (Class-Path: ../lib/one.jar ../lib/two.jar)

Wednesday, January 20, 2010

git color customize

Did you watch the movie Matrix? I think the answer is obviously yes. I am a very good fan of that movie. After watching this movie, my Linux theme, wallpaper , screensaver changed to that theme, specially the terminal. I use Konsole with Green and black schema. So it is a little bit fuzzy when I use “git diff” with default auto color system of git. So I customize the color by editing the “.gitconfig” file on my home directory.

ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = white
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = white bold
[color "status"]
added = yellow
changed = red
untracked = cyan
name = Towhidul Haque Roni
email =

Thursday, January 14, 2010

Make IDEA faster

I was working on a renowned XYZ software company. They prefer IntelliJ IDEA as a IDE. My senor collogue give me some task and I was working on the IDEA. He found the IDE is too slow and suggest me to increase the virtual memory. So I have change it in the “idea.vmoptions” file located on (/idea/bin).
But it seems too slow for scrolling the codes on IDEA. Then my senior suggests me to use version 6 instead of version 8. But I was working with IDEA 8 and looking for a solution. Suddenly senior bro came to me and wanted to see my progress. When he found IDEA version 8 he became angry and warn me he will delete all my code. I was so scared though I have IDEA local history and git ;) . Then I suddenly found the solution that it frequently uses graphics card but I know that it is not NFS(my favorite game :P) so I can disable that by including
At the end of the “idea.vmoptions” file. And the problem solved :D

Wednesday, October 14, 2009

How to setup an ftp server on Linux

[root@roni ~]# yum install vsftpd

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base:

* updates:

* addons:

* extras:

Setting up Install Process

Parsing package install arguments

Package vsftpd-2.0.5-12.el5_3.1.i386 already installed and latest version

Nothing to do

[root@roni ~]# vi /etc/vsftpd/vsftpd.conf

Find and edit


to create a message compliant with the local site policy or a legal disclaimer:

[root@roni ~]# vi /etc/vsftpd/issue


Put whatever your message to the user.......

[root@roni ~]# chkconfig vsftpd on

[root@roni ~]# service vsftpd start

Starting vsftpd for vsftpd: [ OK ]

[root@roni ~]# netstat -tulpn | grep :21

tcp 0 0* LISTEN 29119/vsftpd

[root@roni ~]# vi /etc/sysconfig/iptables

Add this line

RH-Firewall-1-INPUT -m state --state NEW -p tcp --dport 21 -j ACCEPT

[root@roni ~]# vi /etc/sysconfig/iptables-config



[root@roni ~]# service iptables restart

to view the log file

[root@roni ~]# tail -f /var/log/vsftpd.log

Wed Jul 8 08:23:01 2009 [pid 2379] [ftp] FTP command: Client "", "CWD /srv/"

Wed Jul 8 08:23:01 2009 [pid 2379] [ftp] FTP response: Client "", "550 Failed to change directory."

Wed Jul 8 08:23:01 2009 [pid 2383] [ftp] FTP command: Client "", "PWD"

Wed Jul 8 08:23:01 2009 [pid 2383] [ftp] FTP response: Client "", "257 "/""

Wed Jul 8 08:23:01 2009 [pid 2383] [ftp] FTP command: Client "", "CWD /srv/svn/"

Wed Jul 8 08:23:01 2009 [pid 2383] [ftp] FTP response: Client "", "550 Failed to change directory."

Wed Jul 8 08:23:02 2009 [pid 2383] [ftp] FTP command: Client "", "NOOP"

Wed Jul 8 08:23:02 2009 [pid 2383] [ftp] FTP response: Client "", "200 NOOP ok."

Wed Jul 8 08:23:02 2009 [pid 2383] [ftp] FTP command: Client "", "CWD /srv/svn/RONI/"

Saturday, October 10, 2009

How to setup an email Server on Linux

login as: root

root@'s password:

Last login: Tue Jul 7 05:21:48 2009 from

[root@roni ~]# yum install dovecot

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base:

* updates:

* addons:

* extras:

Setting up Install Process

Parsing package install arguments

Resolving Dependencies

--> Running transaction check

---> Package dovecot.i386 0:1.0.7-7.el5 set to be updated

--> Finished Dependency Resolution

Dependencies Resolved


Package Arch Version Repository Size



dovecot i386 1.0.7-7.el5 base 1.6 M

Transaction Summary


Install 1 Package(s)

Update 0 Package(s)

Remove 0 Package(s)

Total download size: 1.6 M

Is this ok [y/N]: y

Downloading Packages:

dovecot-1.0.7-7.el5.i386.rpm | 1.6 MB 00:00

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : dovecot [1/1]

Installed: dovecot.i386 0:1.0.7-7.el5


[root@roni ~]# vi /etc/dovecot.conf

Find and change the following options

protocols = pop3 pop3s imap imaps

mail_location = maildir:~/Maildir/

pop3_uidl_format = %08Xu%08Xv

imap_client_workarounds = delay-newmail outlook-idle netscape-eoh

pop3_client_workarounds = outlook-no-nuls oe-ns-eoh

[root@roni ~]# /sbin/service dovecot start

Starting Dovecot Imap: [ OK ]

[root@roni ~]# telnet localhost pop3


Connected to localhost.localdomain (

Escape character is '^]'.

+OK Dovecot ready.

user roni


pass *****

+OK Logged in.


+OK 0 messages:



+OK Logging out.

Connection closed by foreign host.

[root@roni ~]#

to view the log

[root@roni ~]# vi /var/log/maillog

Start Your Spring development with IntelliJ IDEA in 3 Minutes

Lots of my students and juniors keep telling me that, setting up a “Spring” development environment is a big hassle. There are many tutori...