This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Execution of JAR files and memory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Execution of JAR files and memory" Watch "Execution of JAR files and memory" New topic
Author

Execution of JAR files and memory

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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?


GenRocket - Experts at Building Test Data
Trent DiBacco
Greenhorn

Joined: May 24, 2002
Posts: 18
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

Joined: Apr 20, 2002
Posts: 27
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.


Jack
 
 
subject: Execution of JAR files and memory