Install OpenJDK 8 on Ubuntu 14.04 LTS

Step 1: Add the OpenJDK Team Personal Package Archive (PPA)

Add the PPA:

Once, we run the above command you should be able to see the below message on the command interface.

Install OpenJDK 8 on Ubuntu1

Step 2: The Installation

The best practice is first to update our packages

Once, we run the above command you should be able to see the below message on the command interface.

Install OpenJDK 8 on Ubuntu2

Then install Open JDK 8 with the PPA installer:

Once, we run the above command you should be able to see the below message on the command interface.

Install OpenJDK 8 on Ubuntu3

Step 3: Verify Installation

Now verify that Java is installed by typing:

You will see result similar to:

Once, we run the above command you should be able to see the below message on the command interface.

Install OpenJDK 8 on Ubuntu4

Method Overloading v/s Method Overriding – Java

The capability of more than one objects to respond to the same message in a different way can be broadly categorized into two types:

1. Method Overloading
2. Method Overriding

If we have methods with the same name but having different signatures or behaviors in the same scope than the methods are known as overloaded methods and the process is known as method overloading.

a. A Method can be overloaded in the same class as well as in its sub-class.
b. Constructors can also be overloaded. In this case we call the process as Constructor overloading.

Example-1: Method Overloading –

Method having different return types but not having different signatures cannot be said as overloaded methods because it will result in error stating “signature should be different”.
void display(){
int display(){

e.g. of overloaded methods in System class are print() and println()

Now studying about method overloading in Java rises a question in our minds.
Do you know what is that question?
Read below:
Question – Can We overload main method of Java?
Answer – The simple answer is Yes. This is how we will prove it:


Method overriding means having a different implementation of the same method in the inherited or derived class. These two methods would have the same signature, but different implementation. One of these would exist in the base or the super class and other in the derived class. These methods cannot exist in the same class.

Example-2: Method Overriding –


We use @overrride annotation just before the method to denote an overriden method.

Get the number of lines and characters in a file using Java

This example demonstrates one of the ways to find the number of lines and characters in a file using Java Programming Language.

Here is the block of code that will make the task easy for you.

The file named “file.txt” here in this example is located inside the folder named p3lang on drive E. Change the address in the above program to point the file you want to find the number of lines and characters of.

Here is the visual view of the file “file.txt” and sample contents.
Input File

When we will run this program for the above file and with sample contents in the image. It will produce an output as:
Total number of lines : 3 Length of file: 94

Struts 2.x Netbeans IDE Setup

Struts 2.x is a powerful framework which is used to develop variety of web applications. It is under the control and management of Apache organization and is available as open source. It provides easy and effective way to develop web applications based on MVC pattern. It makes developers easy to work with Servlet and JSP.

To Know more or to Download Libraries visit

In this post We are going to learn about Struts 2.x Netbeans IDE Integration and to develop and run our first web application using Struts.

Here we will first start with Struts 2.x Netbeans IDE Integration. To perform this, We will go through a series of steps as mentioned below:

Download the following software and plugins:

1. Latest Netbeans IDE from to develop web application.

2. To get the support of struts 2.x in our Netbeans IDE We need to download some plugins for the installed netbeans version.
For Example: If you have downloaded the Netbeans IDE Version 7.2 you have to download the following plugins to get Struts 2.x support in Netbeans 7.2:
a. org-netbeans-modules-framework-xwork.nbm
b. org-netbeans-modules-web-frameworks-struts2.nbm
c. org-netbeans-modules-web-frameworks-struts2lib-v2_0_14.nbm
d. org-netbeans-modules-web-frameworks-struts2lib-v2_2_3.nbm

The plugins generally vary depending upon the Netbeans IDE versions. Visit for any information and download regarding struts 2.x plugin support for Netbeans IDE incase you have error in installing the above plugins in your installed Netbeans IDE.

3. After downloading the plugins for your Netbeans IDE install it in your IDE using the following steps:

a. Click on Tools from the menu options.
b. Click on plugins.
c. Click on downloaded option from the new popped window.
d. Select add plugins and browse through the folders to locate the plugins you have downloaded.
e. The final step is to click on install after adding all the plugins.
f. Ignore and Skip any warnings if received.
f. The IDE will be restarted on its own or will ask to restart.
g. After restarting the IDE, you are ready to develop projects using Struts 2.x framework.

Now it’s time to develop our very first program or web application in Struts using Netbeans as IDE.

1. Click on file option from menu (Menu Bar).
2. Click on New Project
3. Select Java Web. You can find it under categories list (on Left) and Web Application (on Right) in the popped window after selecting the twos click Next.
Struts Netbeans
4. After clicking on next a new window will appear or popped on the screen asking you to enter the project name and location to store the project, by default it will have some values:
Struts Netbeans
You can change the name of project or can leave it as highlighted in blue and simply click on next. Here I have stored in my custom folder on drive D. You can make changes from here or leave it as it is.
5. After clicking on Next in the above point i.e. step 4. You will get a new popped window asking for sever by default it will be having glassfish server (It depends upon the version and type of Netbeans IDE installed).
In this example (See the above screenshot), I have used Apache Tomcat Server. If you can see Glassfish Server leave as it is or in case having no server You have to download and add a server.
To download a Glassfish Server visit
After downloading it, Install it in any directory. After Successful installation using the Netbeans IDE popped up window locate and add the installed glassfish server.

After selecting the server, you can leave the rest as it is and click on next.

6. Here is the last step: You will see Struts 2 option under the Framework only in case of successful plugins integration as mentioned in the beginning of this post.
Struts Netbeans
Select Struts2 option and select create example page as shown in the screenshot. After that Click Finish.

You have successfully created the new project “WebApplication1” (As per the project name mentioned by you).

To run your first Struts 2.x web project:
Right click on “WebApplication1” under projects category on the left of window and click run.
Now you can view your web page in the browser!!

Map in Java


adding elements in map