I would like to know how I could store my file in the final executable as raw bytes, that can be read by the program just like regular memory.
Like, I don’t understand why file data that is NEVER manipulated during the program’s runtime, have to be loaded “dynamically” instead of just being stored in the executable’s data section.
Kind of like how you would use linkerscripts (typically non-bytecode languages) to map stuff in the executable’s memory? Only that this would preferably also be done in Java.
I would like to know how I could store my file in the final
Share
Because it’d take longer to load such an executable into memory. Also because it’s 2011, and you have files and a filesystem.
About your first (and primary question), you don’t need to muck about with anything as such. Just tack on your data to the end of the executable and add a final “offset” value to tell you how long it is.
EDIT
I wrote my original answer in the context of a compiled executable, as with C. Since you’ve mentioned Java, afaik, you can put stuff in the final JAR and access it programmatically (since it’s just an archive.)