We are working on a project, that will be distributed using single jar file. We have a need for some key-value store with following properties:
Any suggestions other than BerkelyDB or JDBM2/3?
GNU Trove offers a number of maps (e.g. TIntIntHashMap) that are more memory-efficient than standard Java maps because they use primitive types. I doubt you can get significantly more memory-efficient than this unless you know something about what you are storing. Trove is more or less LGPL, so it's probably safe for you to use. I don't know if it specifically meets your exact specifications, but I think it's worth trying when you can fit things in RAM.
When you might need to swap to disk, Ehcache is a good choice. You can specify that after a certain number of entries it will store values on disk (newly in version 2.5 you can specify after a certain amount of RAM is used if you don't know how the exact number of entries).
Look at noSQL implementations, CouchDB, Cassandra and more are pretty good.
Do google search to compare, you will find what you want.
My favourite is mongoDb and unfortunately its not Java based