• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Execution of JAR files and memory

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you execute a jar file via the command line as follows:
java -jar myJarFile.jar
Is the jar file loaded into memory along with the VM? Or are thier parts of the JAR file that are accessed over and over from it's original location?
 
Trent DiBacco
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a beginner, but if I am not mistaken the -jar parameter just tells the JRE that there is a field in the manifest called Main-Class and to start execution of the class. So i belive it excutes just as if you un-jarred (is that a word) the file and excuted the main file with out the -jar argument.
But what do i know...
 
Jack J. Jackson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trent was essentially correct. Launching an app with the -jar command line switch just tells the runtime to look in the jar for the specified class that declares a main method.
However, the entire jar is not loaded into memory, unlike say a DLL would be. Instead, whenever the virtual machine needs to load a class, it looks in the jar file to find it and then extracts it from the file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic