In my code, I am using several file reading using RandomAccessFile. I am also using JAVA’s in built HashMap. Those causes several page-faults. Is there any in-built library which cares the caching mechanism and easily embed in Java code ?
Edit: I am using JAVAC.
No, This is not simple to do in JAva, or any language unless the language is designed to make use of this from the start.
Fortunately its not something you usually have to worry about as most of your data is likely to be in cache if not main memory (you only get a page fault if the data is not in memory, e.g. on disk)
You can get page faults when reading a file from disk for the first time. It is the job of the OS to ensure your access pattern is dealt with efficiently. If it is not, the best thing to do is a) use a faster drive like an SSD or b) use a different OS. (Unlikely to help)