my code was:
package javaapplication1;
import java.io.Console;
public class JavaApplication1 {
    public static void main(String[] args) {
        Console console =System.console();
        // TODO code application logic here
        String ageInString ;
        ageInString= console.readLine("how old are you?  ");
        int age = Integer.parseInt(ageInString);
        if(age<18)
        {console.printf("not valid");
        System.exit(0);
        }
    }
}
and the error is:
Exception in thread "main" java.lang.NullPointerException
    at javaapplication1.JavaApplication1.main(JavaApplication1.java:20)
Java Result: 1
 
     
     
    