• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Couple of questions on jar files.

 
Ranch Hand
Posts: 112
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have couple of questions related to jar files. As we know jar files are zipped files which contains classes and other manifest files in it.

1.My first question is, since it is a zipped file, how can an application locate a specific class from it at runtime...is it that applications extract the contents of jar files at runtime and then pick up an appropriate class?. Is there any special mechanisms that come into picture here?

2.Can jar files be delay loaded just as dlls.

Thanks,
Pavan.
 
Ranch Hand
Posts: 1164
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do one thing. Copy any jar file to the desktop. Extract its contents to a folder. Then open the manifest file and see what does it contain. Let me know in case you have further doubts..
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why to the desktop?
 
Mansukhdeep Thind
Ranch Hand
Posts: 1164
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Why to the desktop?


Not necessary to desktop only. Important thing is to copy at a separate place and then extract, not the original archive. There is a chance it might get corrupted.
 
Marshal
Posts: 28175
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Extracting data from a jar file might corrupt the jar? That's extremely unlikely.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mansukhdeep Thind wrote: . . . Important thing is to copy at a separate place and then extract, not the original archive. There is a chance it might get corrupted.

Agree. Create a temporary folder, extract it inside that, then you can delete the folder.


And if you are careless and didn’t copy it, the jar file too
 
Pavan Kumar Dittakavi
Ranch Hand
Posts: 112
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,..sorry for the late reply. I have extracted a jar file and I could see different type of entries in it for instance, the version of the jar file, the jdk version that has been used for creating it and other entries like the main method that would get executed if one tries to run the jar file.

Just wanted to convey one of my questions again. Since jar file sort of compresses/binds together different classes, would they be unbundled/extracted when the jvm decides to run on of the classes' methods,...say for instance its main method.

Thanks,
Pavan.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pavan Kumar Dittakavi wrote:1.My first question is, since it is a zipped file, how can an application locate a specific class from it at runtime...is it that applications extract the contents of jar files at runtime and then pick up an appropriate class?. Is there any special mechanisms that come into picture here?


Unless it specifically says something about this in the Java language Specification, then it is probably entirely up to the JVM developer whether they extract all the files in one go or just extract them as needed.

Pavan Kumar Dittakavi wrote:2.Can jar files be delay loaded just as dlls.


Jar files are not loaded - classes are. And classes are only loaded when they are required.
reply
    Bookmark Topic Watch Topic
  • New Topic