How to start an embedded server from an application

In one thread, the embedding application starts the local JDBC driver for its own access.

/*
    If you are running on JDK 6 or higher, you do not
    need to invoke Class.forName(). In that environment, the
    EmbeddedDriver loads automatically.
*/
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
Connection conn = DriverManager.getConnection(
    "jdbc:derby:sample");

In another thread, the same application starts the server framework to allow remote access. Starting the server framework from within the application allows both the server and the application to run in the same JVM.

Related concepts
Connectivity configurations
Multiple-client features available in Derby
The Derby Network Server
Embedded servers
Related reference
Embedded server example