My projects usually have a folder structure like this:
/src
/main
/java
/resources
/test
...
(because I use Maven; Launch4J has a good Maven plugin, btw.).
I put all images, that need to be available for the application, into the /resources
folder.
During the build process, images are copied into the output folder, where all the compiled .class
files are. The images are now in the classpath.
To access resources (i.e. images) in your classpath, you can use the classloader, such as:
Resources in the root directory (
src/main/resources/image.jpg
) can be accessed through the System ClassLoader:ClassLoader.getSystemResource("image.jpg"); ClassLoader.getSystemResourceAsStream("image.jpg");
Resources in other packages (e.g. for
com.example.MyClass
the resource should be atsrc/main/resources/com/example/image.jpg
) can be accessed through the class itself:MyClass.class.getClassLoader().getResource("image.jpg");
Launch4J never complains about that and uses the images without any problem, even in .exe files.