I am trying to create an in-memory database (I do not need any files -log or database- to be stored on disk) , do calculations, save the calculations and terminate it. I cannot seem to locate an example in JE to create an in-memory database. As far as I get from the documentation this should be possible but I was not able to change examples to fit my need. Can you please point me to a document or an example that covers this?

I presumed that this meant in-memory (from ~GettingStartedGuide/usingDbt.html#datapersist):

If you do not want to use transactions, then the assumption is that your data is of a nature that it need not exist the next time your application starts. You may want this if, for example, you are using JE to cache data relevant only to the current application runtime.

I changed an example to get rid of transactional code and save 1MM records into the table. It's not saving the data that I am saving into the database. It does it when database is opened and closed. This must be what is described in the above paragraph. I understand that if BDB consumes all memory there will be caching for this operation.

Durability, transactions, temporary databases and in-memory databases are all different things, and each is a topic all on its own. Rather than try to describe all of that, it would help if you could describe exactly what you want to do, and why -- what is the purpose of your questions -- so I can better give you the information you need.

I noticed in your code example, you're using temporary databases -- you're calling DatabaseConfig.setTemporary(true). If you don't need the data to be persistent, this is the right thing to do. If you're asking how temporary databases work, see:
http://docs.oracle.com/cd/E17277_02/html/java/com/sleepycat/je/DatabaseConfig.html#setTemporary(boolean)
and
http://docs.oracle.com/cd/E17277_02/html/GettingStartedGuide/DB.html#tempdbje

However, you should also ask yourself why you're using a database. Why not just just a HashMap or TreeMap? If you can answer this question, it will help to understand the problem you're trying to solve.