[[server-embedded]]
Using the server (with web interface) with an embedded database
===============================================================

Even if you are using the Neo4j Java API directly, for instance via +EmbeddedGraphDatabase+ or +HighlyAvailableGraphDatabase+, you can still use the features the server provides.

== Getting the libraries ==

=== From the Neo4j Server installation ===

To run the server all the libraries you need are in the 'system/lib/' directory of the http://neo4j.org/download/[download package].
For further instructions, see <<tutorials-java-embedded-setup>>.
The only difference to the embedded setup is that 'system/lib/' should be added as well, not only the 'lib/' directory.

=== Via Maven ===

For users of dependency management, an example for http://maven.apache.org[Apache Maven] follows. 
Note that the web resources are in a different artifact.

.Maven pom.xml snippet
["source","xml","unnumbered","2",presubs="attributes"]
------------------------------------------------
<dependencies>
  <dependency>
    <groupId>org.neo4j.app</groupId>
    <artifactId>neo4j-server</artifactId>
    <version>{neo4j-version}</version>
  </dependency>
  <dependency>
    <groupId>org.neo4j.app</groupId>
    <artifactId>neo4j-server</artifactId>
    <classifier>static-web</classifier>
    <version>{neo4j-version}</version>
  </dependency>
</dependencies>
<repositories>
  <repository>
    <id>neo4j-snapshot-repository</id>
    <name>Neo4j Maven 2 snapshot repository</name>
    <url>http://m2.neo4j.org/content/repositories/snapshots/</url>
    <releases>
      <enabled>false</enabled>
    </releases>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </repository>
</repositories>
------------------------------------------------

=== Via Scala SBT / Ivy ===

In order to pull in the dependencys with https://github.com/harrah/xsbt/wiki[SBT] and configure the underlying http://ant.apache.org/ivy/[Ivy]
dependency manager, you can use a setup like the following in your +build.sbt+:

["source","scala","unnumbered","2",presubs="attributes"]
----
organization := "your.org"

name := "your.name"

version := "your.version"

/** Deps for Embedding the Neo4j Admin server. */
libraryDependencies ++= Seq(
  "org.neo4j.app" % "neo4j-server" % "{neo4j-version}" classifier "static-web" classifier "",
  "com.sun.jersey" % "jersey-core" % "1.9"
)

/** Repos for Neo4j Admin server dep */
resolvers ++= Seq(
  "maven-central" at "http://repo1.maven.org/maven2",
  "neo4j-public-repository" at "http://m2.neo4j.org/content/groups/public"
)
----

== Starting the Server from Java ==

The Neo4j server exposes a class called
http://components.neo4j.org/neo4j-server/{neo4j-version}/apidocs/org/neo4j/server/WrappingNeoServerBootstrapper.html[WrappingNeoServerBootstrapper],
 which is capable of starting a Neo4j server in the same process as your application.
It uses an
http://components.neo4j.org/neo4j-kernel/{neo4j-version}/apidocs/org/neo4j/kernel/AbstractGraphDatabase.html[AbstractGraphDatabase]
instance that you provide.

This gives your application, among other things, the REST API, statistics gathering and 
the web interface that comes with the server.

.Usage example
[snippet,java]
----
component=neo4j-server
source=org/neo4j/server/WrappingNeoServerBootstrapperTest.java
tag=usingWrappingNeoServerBootstrapper
classifier=test-sources
----

Once you have the server up and running, see <<tools-webadmin>> and <<rest-api>> for how to use it!

== Providing custom configuration ==

You can modify the server settings programmatically and, within reason, the same settings
are available to you here as those outlined in <<server-configuration>>.

The settings that are not available (or rather, that are ignored) are those that concern
the underlying database, such as database location and database configuration path.

.Custom configuration example
[snippet,java]
----
component=neo4j-server
source=org/neo4j/server/WrappingNeoServerBootstrapperTest.java
tag=customConfiguredWrappingNeoServerBootstrapper
classifier=test-sources
----


