Lets say I want to load an image, "img.gif", would it be better to load it from the .JAR, or load it from the harddrive? Which is more efficient(speed, and memory usage), or are they essentially equal? I understand that loading from the classpath may be more convenient, but I'm disregarding that.
Loading from a resource packed inside the jar is usually better because you can guarantee that the resource is always going to be there. Having the resource located somewhere else on the filesystem increases the chance that it could move or disappear.
Also having the resource inside the jar makes the jar more portable and available on different Operating Systems with different filesytems or on different machines with different folder structures.
I'm not sure if you would notice a speed difference eitherway.
Smells of premature optimization, but a JAR file is a type of ZIP file that's written on a harddrive. Since reading the bytes off the harddrive directly avoids decompression it's probably faster. Of course, you should only need to read and decompress them once. Finally, images aren't typically compressible with LZW but jar provides additional advantages in terms of software deployment and maintenance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With