Thanks for the link. As per the suggestion at the link, it worked.
1) xhost +localhost
2) su -
3) export DISPLAY=localhost:0.0
But why (1) has to be executed as a normal user? Why not as root
itself since root has all the powers? I tried executing (1) & (3) as
root but didn't work. Just wondering what might be the reason.