aspose file tools*
The moose likes Java in General and the fly likes Where are loaded classes cached Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Where are loaded classes cached" Watch "Where are loaded classes cached" New topic
Author

Where are loaded classes cached

Ondrej Homola
Greenhorn

Joined: Jul 14, 2010
Posts: 2
Hi,

I have this small problem with class loading:

When I run a java program, with classpath to a remote jar on a really slow network, it takes a while to load the classes (that is okay).

But if I run the same program again just seconds after, the classes will be loaded immediately. Does that mean, the classes are cached on a disk in the java's cache directory?
Strangely it only works, if I re-run the application until 20 seconds or so. Which also makes it difficult to search for the cached classes on the disk to prove my thought.

I did some network data profiling though. Only the first (slow) run actually downloads the classes from the remote disk.

If there really is some class caching, could anyone point me to some documentation on it?


Thanks a lot.

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40


It's highly unlikely that this has anything to do with the JVM caching classes, and more likely... it's related to the OS doing file caching.

Many network file systems, NFS, SMB, etc., support some type of change detection and file caching.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39380
    
  28
And welcome to the Ranch
Ondrej Homola
Greenhorn

Joined: Jul 14, 2010
Posts: 2
Thanks for reply, okay I would happily accept that as an explanation, but ...

A program like this ... :


... causes the file to be loaded via the network evey time, so the caching doesn't take place. Shouldn't the OS cache both the File and the .jar in the same way?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

http://faq.javaranch.com/java/AvailableDoesntDoWhatYouThinkItDoes


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14266
    
  21

Ondrej Homola wrote:... causes the file to be loaded via the network evey time, so the caching doesn't take place. Shouldn't the OS cache both the File and the .jar in the same way?

I guess that files on the network will not be cached in memory by the operating system, because (unlike files on the local harddisk) the operating system does not have full control over them - some other computer may change the file anytime.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where are loaded classes cached