Exception in thread "main" when calling methods from switch in menu class
<p>My problem is: 
When I'm trying to call method newFile.createYear(); from switch in menu terminal prints error:</p>

<pre><code>Exception in thread "main" java.lang.NullPointerException
at com.register.file.CreateFile.showYears(CreateFile.java:140)
at com.register.file.CreateFile.createYear(CreateFile.java:30)
at com.register.main.Menu.registers(Menu.java:30)
at com.register.main.Menu.menu(Menu.java:132)
at com.register.main.Main.main(Main.java:14)
</code></pre>

<p>Problem does not occur when I'm running program inside eclipse. I'm running program by typing <code>java com.register.main.Main</code> in terminal.</p>

<p>Additionally when I'm trying to go back to last menu, after calling a method, (even in Eclipse):</p>

<p>The part of code from switch:</p>

<pre><code>    switch (selection) {
            case 1:
//method that clearing terminal (I can't find anything better :( )
                newClear.clearConsole();
//method that work only in eclipse, not terminal
                newFile.createYear();
//name of current menu (back option) - doesn't work
                registers();

                break;

&gt; Exception in thread "main" java.util.NoSuchElementException   at
&gt; java.util.Scanner.throwFor(Unknown Source)    at
&gt; java.util.Scanner.next(Unknown Source)    at
&gt; java.util.Scanner.nextInt(Unknown Source)     at
&gt; java.util.Scanner.nextInt(Unknown Source)     at
&gt; com.register.main.Menu.registers(Menu.java:24)    at
&gt; com.register.main.Menu.registers(Menu.java:31)    at
&gt; com.register.main.Menu.menu(Menu.java:134)    at
&gt; com.register.main.Main.main(Main.java:14)
</code></pre>

<p><a href="https://github.com/JakubKacperski/Register" rel="nofollow">https://github.com/JakubKacperski/Register</a></p>