How to read input from keyboard?

I got stuck while solving a coding challenge ,everything is good including the logic,but the problem is i am unable to read the input from keyboard ,it showing an exception like NoSuchElementException. Now how to overcome it ?

Share your code with me!
Also, have you imported Scanner outside main?