I use this code to display image that locates outside the my java project, but I got NullPointerException every time and I can only use images that are inside my project directory. why ?
Icon welcomeImg = new ImageIcon(getClass().getResource("D:/img/welcome.png"));
or
Icon welcomeImg = new ImageIcon(getClass().getResource("D://img/welcome.png"));
JLabel welcomingLb = new JLabel(welcomeImg);