# Runtime Control in Java

> The startup procedure that initializes the eXtremeDB runtime environment in Java applications is implemented in the Database.runtimeStart() method which is invoked automatically by the constructor when a Database object is instantiated. And Database.runtimeStop() is invoked automatically to shutdown the runtime in an orderly manner when the Database object is destroyed.

> ## Runtime Libraries

> For Java applications, the runtime library options are specified in the Database constructor call. There are three constructors for the Database class:

>         Database()

>         Database(int config)

>         Database(Database db)

> The first (default) constructor loads the default runtime which uses conventional memory for all-in-memory databases and the `MURSIW` transaction manager in the release mode libraries. The third constructor is for opening secondary databases. It inherits the library configuration from a previously opened database.

> The second constructor allows selecting which runtime libraries to load. Prior to instantiating the Database object, it is common practice to set runtime options to load specific eXtremeDB DLLs by setting Database.Mode values. (See page Java Runtime Libraries for the list of available runtime libraries.)

> These runtime library options are typically set using the '|' operator to combine flags. For example:

>         db = new Database(Database.MCO_CFG_DEBUG_LIBRARY | Database.MCO_CFG_MVCC_TRANSACTION_MANAGER);

> ## Persistent Databases

> For Java Persistent Database applications, the dynamic library options are specified, as for In-Memory database applications, in the Database constructor call. To open a persistent database, the `MCO_CFG_DISK_SUPPORT` flag is specified in the Database constructor call. For example:

>         db = new Database(Database.MCO_CFG_DEBUG_LIBRARY|Database.MCO_CFG_DISK_SUPPORT);

> ## getRuntimeInfo

> The Database.getRunTimeInfo() method can be called any time after Database instantiation to obtain the specific configuration details of the current runtime. (Please refer to SDK sample java/open for an example.)

> The typical sequence of API calls would look like the following:

>         public static void main(String[] args)
>         {
>             Database db;
>             ...
>             int config = Database.MCO_CFG_SHARED_MEMORY | Database.MCO_CFG_MVCC_TRANSACTION_MANAGER;
>             ...

>             config |= Database.MCO_CFG_DEBUG_LIBRARY;

>             // Initialize runtime and open database with shared memory, MVCC and debug libraries
>             db = new Database(config);
>             // Call method getRunTimeInfo() to view runtime options
>             Database.RuntimeInfo ri = db.getRunTimeInfo();
>             ...
>         }