I am trying to run an application in netbeans, but regularly getting bellow given error:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:217)
at Login.<init>(Login.java:36)
at Login.main(Login.java:90)
C:\Users\MyPc\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)
The image is used in line 36 as:
btnLogin = new JButton("Login", new ImageIcon(ClassLoader.getSystemResource("Images/login.png")));
This question is different as already answered questions have been reviewed but none of them are able to solve the issue. Similar questions can be different depending upon particular environment.