Which icon is displayed for a file is up to the OS you are using, not the program that creates the file. AIUI the OS associates the file extension with an icon. To set your own icon, you'll have to get the OS to associate your icon with your file extension.

Java can't really help with this, it is designed to be platform agnostic, so it has few OS specific facilities. I'd be inclined to use a native language (e.g. C/C++ or C# with Windows) or a OS-supported scripting language.

The tools we use have a profound (and devious!) influence on our thinking habits, and, therefore, on our thinking abilities...
E. Dijkstra