Mockito can only mock visible & non-final classes

While using Test Driven Development(TDD) we need to mock class/interface for the testing purpose. I recently came through this error “Mockito can only mock visible & non-final classes” while using mockito to mock an interface. Everything was looking fine, yet I was getting – “Mockito can only mock visible & non-final classes” error.

Finally I got rid of the error after some searching. It was due to use of early version of JDK8. So I updated my JDK to latest version and the error was gone.

So, please update your JDK to latest version to resolve the problem.

Thank you.



Manohar Bhattarai

Posted in Java, Test driven development Tagged with: , , ,

Safely increase size of a column in a PostgreSQL table without changing data

Sometimes we find that the size of a column is not sufficient to hold the data we need to store. We need to safely increase size of a column in a PostgreSQL table without changing data.

Say, we have default varchar(255) and we wish to make varchar(1000). We don’t want to change the data in the existing records and just increase the size from 255 to 1000.

The ALTER TABLE ...ALTER COLUMN...TYPE... com­mand is use­ful if we want to alter the data some­how, or change the data type. We have different ways to increase the size of the column, I use the following way to do it.

Let us say, we have a table “MY_TABLE” with column “MY_COLUMN” which has initial size of 255 and we want to increase its size to 1000.

First of all, let us check the initial size with following query:

SELECT atttypmod FROM pg_attribute
WHERE attrelid = 'MY_TABLE'::regclass
AND attname = 'MY_COLUMN';
(1 ROW)

This shows that the size is 259 (4 is added for legacy rea­sons). We can now safely change this to a varchar(1000) size by issu­ing this query:

UPDATE pg_attribute SET atttypmod = 1000+4
WHERE attrelid = 'MY_TABLE'::regclass
AND attname = 'MY_COLUMN';

I added the 4 to the size of 1000, for some legacy rea­sons inside PG.


You can again check the size with the first query above.

Thank you.

Posted in Postgres Tagged with: , , , , , , , , , ,

Google is now Alphabet

Goodbye Google, and hello Alphabet. Google has a new parent company, Alphabet. Along with the new name, some of Google’s businesses are splitting off to become their own separate companies under Alphabet. The restructuring process was completed on October 2, 2015.

On August 10, 2015, Google Inc. announced plans to create a new public holding company, Alphabet Inc. Google CEO Larry Page made this announcement in a blog post on Google’s official blog. Alphabet will be created to restructure Google by moving subsidiaries from Google to Alphabet, narrowing Google’s scope. The company will consist of Google, Nest Labs, and Calico, as well as other businesses including Google X, Google Capital, and Google Ventures. Sundar Pichai, current Product Chief, is to become the new CEO of Google, replacing Larry Page.

Alphabet Inc. will replace Google Inc. as the publicly-traded entity and all shares of Google will automatically convert into the same number of shares of Alphabet, with all of the same rights. Google will become a wholly-owned subsidiary of Alphabet. Our two classes of shares will continue to trade on Nasdaq as GOOGL and GOOG.

Google does not own alphabet dot com. You can visit its website abc dot xyz for the announcement by Larry Page, the CEO of Alphabet.

Google is now Alphabet. G is for Google.

Please visit wikipedia and other sites for detailed information.

Manohar Bhattarai

Posted in Google Tagged with: , , , , , , , ,

Happy New Year 2015

I wish you all a very very Happy and Prosperous New Year 2015 A.D.

Manohar Bhattarai

Posted in Happy New Year Tagged with:

Google Introduces Auto Awesome Photobombs with David Hasselhoff

Hello all,

Google just introduced auto awesome photobombs with David Hasselhoff for Google+. Google+ Auto Awesome is all about fun surprises that bring your photos to life.

Just upload a new self-portrait, or a group photo with friends, and leave some room for The Hoff. He might just make your photo a little more #Hoffsome.

For more see this post from google.

Please apply your own mind though.

Manohar Bhattarai (मनोहर भट्टराई)
Personal Website :
Personal Blog :



Posted in April Fools Day Tagged with: , , , , , ,

Happy New Year 2014

Hello everyone,

I wish you all a very very Happy New Year 2014. I wish you all a prosperous and successful year ahead. May this year bring peace and prosperity to everyone in the world.

Manohar Bhattarai (मनोहर भट्टराई)
Personal Website :
Personal Blog :

Posted in Blog, Happy New Year Tagged with: , , , ,

psql: FATAL: password authentication failed for user – error in Postgresql

Hi all,

I am writing after a long time. This will be a short post on the error we get in postgresql. The error is : psql: FATAL:  password authentication failed for user “username”.

The following code snippet shows the errors when password is prompted and (1) password is not supplied (2) wrong password is supplied:

manohar@manohar-desktop:~$ psql simulator
psql: fe_sendauth: no password supplied
manohar@manohar-desktop:~$ psql simulator
psql: FATAL: password authentication failed for user "manohar"

The above error is normally due to wrong password or you have not set the password for that user already. You can change the password for the user to login to the database again. You can check how to install and do the settings for postgresql in Ubuntu 12.04 here.

The following code snippet shows how to overcome the above error by changing the user’s password:

manohar@manohar-desktop:~$ sudo su - postgres
postgres@manohar-desktop:~$ psql simulator
psql (9.1.10)
Type "help" for help.

simulator=# alter user manohar with password 'newPassword';
simulator=# \q
postgres@manohar-desktop:~$ exit
manohar@manohar-desktop:~$ psql simulator
psql (9.1.10)
Type "help" for help.




Hope this helps you all.

Manohar Bhattarai (मनोहर भट्टराई)
Personal Website :
Personal Blog :

Posted in Postgres, Ubuntu 12.04 LTS Tagged with: , , , , , , ,

Douglas Engelbart, inventor of computer mouse, dead

Douglas Engelbart

Computing visionary Douglas Engelbart, the visionary electrical engineer who invented the computer mouse, died at his California home on Tuesday, 2nd July, 2013. He was 88.

His work is the very foundation of personal computing and the Internet. His vision was to solve humanity’s most important problems by using computers to improve communication and collaboration. He was world famous for his invention of the computer mouse and the origins of interactive computing. His work at SRI, then called the Stanford Research Institute, resulted in 21 patents. The last one, granted in 1970, was for the mouse. “I don’t know why we call it a mouse,” he said, except, it resembled a rodent, with its cord as a tail.

Manohar Bhattarai (मनोहर भट्टराई)
Personal Website :

Posted in Blog Tagged with: , , , , , , , , , , ,

How to enable hibernate in ubuntu 12.04

Hi all,

The hibernate menu is disabled by default in ubuntu 12.04 due to some reasons like it din’t work in many computers. So you can re-enable it in ubuntu 12.04. Here is how you can enable hibernate in ubuntu 12.04 LTS.

Be Safe – Always save your work before hibernating.
First check if hibernate works correctly in your system. You can use the command line to test if hibernate works on your computer.
a. Open the Terminal by pressing Ctrl+Alt+t or by searching for terminal in the dash.
b. Now type sudo pm-hibernate into the terminal and press Enter.
Enter your password when asked.
c. After the computer turns off, switch it back on. Did your open applications re-open?
If hibernate doesn’t work, check if your swap partition is at least as large as your available RAM.

To enable the hibernate option in the menus, use your favorite text editor to create/edit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla file. Add the following to the file and save:
[Re-enable hibernate by default]

Restart your computer and hibernate option is back!
Or run killall unity-panel-service to just reset the menu.
Some users will then need to run sudo update-grub to get the hibernate option to be available in the power menu.

You can follow official documentation here.

Manohar Bhattarai (मनोहर भट्टराई)
Personal Website :
Personal Blog :

Posted in Ubuntu Tagged with: , , , , , , , , , , , , , , ,

How to enable java applet in the browser

Hi all,

Sometimes we find that java applet is not working on our browser even if we have java installed on our machine.
So, let us see how to enable java applet in the browser like firefox or chrome in linux(Ubuntu).
For this we need to have the java applet plugin “” for the browser.

Let us see how to add the plugin:

Close the browser first to be sure, but it worked for me without closing.
1. Find the “” plugin in your java installation. For me the plugin is located in “/home/manohar/java/jre/lib/i386/” where “/home/manohar/java/” is my java installation directory.

  1. Go to your home directory using the command :
    cd ~

  2. Give the command to find where the plugins are located :
    For chrome: locate *.so | grep chrome
    For firefox: locate *.so | grep mozilla

  3. Change to the directory where the most of the plugins are located. In my machine, it is “/opt/google/chrome/” for chrome and “/usr/lib/mozilla/plugins/” for firefox. So give the following command :
    For chrome: cd /opt/google/chrome/
    For firefox: cd /usr/lib/mozilla/plugins/

  4. See if old plugin exists, if so, remove the old plugin with :

  5. Create a link to “” plugin by giving the command :
    sudo ln -s /home/manohar/java/jre/lib/i386/

Now start the browser and you can see the java applet working. Or you might have to click “Run this time” button which popped just below the address bar to enable the plugin on that page.

Hope this helps and works for you all and saves you the day. Please share your experience through the comments and if it works for other flavors of linux (I did in Ubuntu). This site helped me.

Manohar Bhattarai (मनोहर भट्टराई)
Personal Website :
Personal Blog :


Posted in Java, Ubuntu Tagged with: , , , , , , , , , , ,

About the Author

manoharbhattarai.jpgI am Manohar Bhattarai. A vivid java programmer. I boot Ubuntu Linux. Follow me @mhrbhattarai on twitter. You can LIKE me on my facebook page.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 12 other subscribers

Subscribe RSS feed

Gravatar Profile

Manohar Bhattarai

Manohar Bhattarai

I am Manohar Bhattarai, a vivid java programmer. A keen Linux user. I currently boot Ubuntu Linux.

Personal Links

Verified Services

View Full Profile →

Follow me on Twitter

September 2016
« Feb    
%d bloggers like this: