By the time of deployment, those resources will likely become an embedded-resource. That being the case, the resource must be accessed by URL
instead of File
. See the info page for the tag, for a way to form an URL
.
Accessing a saved file in a .exe. Java
Question
I have written a program in java and have stored some data in a txt file. I then made the project into an .exe file using launch4j, and I was wondering how I can access the data stored in the file which should be in the .exe.
I have tried using getClass().getResource(file).path(); to get the file path, but this doesn't seem to work.
Solution
OTHER TIPS
If you used wrapping option of launch4j, then you cannot simply obtain resources from .exe. You would have to somehow parse/reverse engineer the exe file to obtain just the .jar content.
I doubt that there is some software for this, since you can simply decide not to wrap the jar with exe in the first place. Then you will have separate .exe file that server as a launcher for a independent .jar file. Its quite easy solution and really simple in an application.