you have to make sure the Icon is available. That's not about the code, it's more about you organizing the resources.
Please make a folder "resources" aside of the folder "src". That is common sense.
In "resources" you'll create a folder "icons" and put the icon in there. Then reference that path and get the icon:
String path = ResourcesLoader.class.getResource("/resource/icons/icon.png").toString();
Should do the trick (depending on what type of project you run)
You can add more in the resource folder - like a folder "properties" with some property files in there.
make sure you deploy the icon with the app - mark the icon / the complete resources to become a part of the deployment.