This option will upgrade first the database file format and then defragment it. You need to specify a folder where the temporary data for this process is stored.
DefragmentConfig config = new DefragmentConfig("database.db4o"); config.upgradeFile(System.getProperty("java.io.tmpdir")); Defragment.defrag(config);