First of all, this is not a duplicate of the very common question of making an EXE from Java classes. I do not need to do that.
To solve NetBeans RFE #64612 without manual steps I need a Java (6+) library which can take an existing Windows *.exe
file and replace its icon with a substitute in a common format. The executable, which is generic and prebuilt (distributed in binary form), already knows how to load an application-specific config file and then start the JRE with various application JARs etc.; the only problem is that it has a generic icon, and I would like to replace that icon as part of a pure Java build with an application-specific icon, so it looks prettier.
The library must be available under a nonviral open-source license; cross-platform (must run on Windows, Linux, Mac, Solaris) so cannot fork some OS-specific helper tool; and must accept PNG input, though the EXE must work on XP so according to Wikipedia should embed BMP format. At a high level, supposing Ant as a build tool, I would like something like this:
<replaceicon from="app.exe" to="hello.exe" icon="hello.png"/>
Does anyone know if a tool matching these specifications already exists? From various web searches I found Launch4J, but this appears to just fork windres for the real work, thus not trivially portable. I found JSmooth which looks more promising - appears to include Java code to handle the ICO codec and manipulate PE files - but it is GPL. WinRun4J looks to use native code for icon manipulation, though I had a hard time following its sources. Jimi supposedly handles the ICO format (for that matter the standard javax.imageio
seems to as well) but I guess has no facility for updating PE resources.