In order to solve the problem you must find the line that causes this exception. Java shows the line number of the error in the error message.
Exception in thread "main" java.lang.NullPointerException
at SomePackage.SomeClass.main(SomeClass.java:6)
In most of the IDEs (Integrated Development Environment) you can click the line number and reach the error immediately. By this way you can see which variable is null and you can initialize that variable. Of course this is not the only solution for this exception, since there are lots of causes for java.lang.NullPointerException, however most of the problems can be solved by this approach.