random access indexed file for java objects' serialization

I am implementing a stategy for managing java object in memory thru swapping between memory & disk. I have throught of persistence mechanism for each object using java's object serialization. These objects are stored in an object array. This strategy works fine for small number of objects and give good results. But in real scenario (the software tool where i am going use this strategy), there can be object count ranging from 50k to 500k. So serializing a each object to a file does not work for me, as the number of files in the disk will be a number where it becomes unmanagable by the OS or JVM. So I am planning to write all the objects to a indexed file. I will access the Objects randomly from that file whenever needed. These objects differ in sizes and object size can increase or decrease during the run.

First I'd wonder wether someone already implemented such an algorithm.

I'd also probably consider using a lightweight OO database.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus