0

Take a standalone executable jar file for example, in which we generate from our application with all the dependencies etc. My understanding is that this file contains all the classes etc. compressed.

When we execute this jar file via the command line as follows java -jar myjar.jar , is this being decompressed on the fly? Does the interpreter first decompress everything before executing or how does this work exactly?

Engineer999
  • 3,683
  • 6
  • 33
  • 71

1 Answers1

0

We already have one answer to similar question here : How does a jar file get executed? Do the classes get extracted somewhere?

The JVM is capable of loading classes or files from a jar file without extracting the jar to temp files.This functionality is also available to you in the standard library, see the JarFile for more information.

So no, the JVM does not extract a jar to temp files, classes (and resources) are simply loaded on demand.

We can also check if the jar gets extracted or not by executing the command "java -jar myjar.jar" and check the folder where jar is located if there is any extraction while executing the program.