Starting With Embedded Mode
In most scenarios, you would use GridGain CLI tool to start and manage your GridGain cluster. However, in some scenarios it is preferable to manage the cluster from a Java project. Starting and working with the cluster from code is called "embedded mode".
This tutorial covers how you can start GridGain 9 from your Java project.
Prerequisites
This section describes the platform requirements for machines running GridGain. GridGain system requirements scale depending on the size of the cluster.
JDK |
11 and later |
OS |
Linux (Debian and Red Hat flavours), Windows 10 or 11 |
ISA |
x86 or x64 |
Add GridGain to Your Project
First, you need to add GridGain to your project. The easiest way to do this is add GridGain to your project is by using Maven:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>GridGain External Repository</id>
<url>https://www.gridgainsystems.com/nexus/content/repositories/external</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.gridgain</groupId>
<artifactId>ignite-api</artifactId>
<version>9.0.12</version>
</dependency>
<dependency>
<groupId>org.gridgain</groupId>
<artifactId>ignite-runner</artifactId>
<version>9.0.12</version>
</dependency>
</dependencies>
Prepare GridGain Configuration
To start a GridGain node, you will need a GridGain configuration file that specifies all configuration properties of the node. For this tutorial, we recommend installing GridGain 9 and using a default configuration file from it. This file is stored in the gridgain9-db-9.0.12/etc/gridgain-config.conf
file.
Pass JVM Parameters
The following JVM parameters need to be passed to your application to make proprietary SDK APIs available:
--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/jdk.internal.access=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true
Start GridGain Server Nodes
To start a GridGain node, use the following code snippet:
IgniteServer node = IgniteServer.start("node", configFilePath, workDir);
This code snippet starts a GridGain node with the name node1
, that uses the configuration from the file specified in the configFilePath
path parameter and uses the folder specified in the workDir
path parameter to store data. When the node is started, this method returns an instance of IgniteServer
class that can be used to work with the node.
Initiate a Cluster
Started nodes find each other by default, but they do not form an intractable cluster unless the cluster is initiated. You need to initiate the cluster to activate the node. If there are multiple nodes, once the cluster is activated, they will form a topology and automatically distribute workload between each other.
Use the code snippet below to initiate a cluster:
InitParameters initParameters = InitParameters.builder()
.metaStorageNodeNames("node")
.clusterName("cluster")
.clusterConfiguration({config-with-license})
.build();
node.initCluster(initParameters);
Get an Ignite Instance
Now that the cluster is started, you can get an instance of the Ignite
class:
Ignite ignite = node.api();
This instance can be used to start working with the cluster. The future will be returned once the cluster is active.
In the following example, you interact with the cluster using the SQL API:
ignite.sql().execute(null, "CREATE TABLE IF NOT EXISTS Person (id int primary key, name varchar, age int);");
ignite.sql().execute(null, "insert into Person (id, name, age) values ('1', 'Person Man', '501'");
try (ResultSet<SqlRow> rs = ignite.sql().execute(null, "SELECT id, name, age from Person")) {
while (rs.hasNext()) {
SqlRow row = rs.next();
System.out.println(" "
+ row.value(1) + ", "
+ row.value(2));
}
}
More examples of working with GridGain can be found in the examples repository.
Next Steps
From here, you may want to:
-
Check out the Developers guide page for more information on available APIs
-
Try out our examples
© 2025 GridGain Systems, Inc. All Rights Reserved. Privacy Policy | Legal Notices. GridGain® is a registered trademark of GridGain Systems, Inc.
Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are either registered trademarks or trademarks of The Apache Software Foundation.