Skip to main content

JAR loading question

3 replies [Last post]
java_account
Offline
Joined: 2009-03-06

Hi,

Can you tell me or point me to the right website about how the jar files loaded when the application is started? I have a client jar(which has the main class) that resides on a share drive. Also, there are jars that are used as library(db connection ..).
How are those jars loaded?

Thanks a lot

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
peter__lawrey
Offline
Joined: 2005-11-01

JARS are typically loaded using the URLClassLoader. If you want to know how it works I suggest you read the source code.
Do you have specific questions in mind?

java_account
Offline
Joined: 2009-03-06

Let say I have myapp.jar, j1.jar,j2.jar in my classpath. When I start the app, how are the jars are loaded into memory?

Is the whole jar loaded at once or only needed classes?
Does it depend on the size of the jar ?

Thanks for you help

peter__lawrey
Offline
Joined: 2005-11-01

> Let say I have myapp.jar, j1.jar,j2.jar in my
> classpath. When I start the app, how are the jars are
> loaded into memory?
As required.
>
> Is the whole jar loaded at once or only needed classes?
The index for the jar is loaded as required and then classes are loaded as required. This means you could be missing a class (e.g. you have an incorrect/missing jar) and you won't know until something attempts to load the missing class from it.
> Does it depend on the size of the jar ?
no.