This section discusses how to obtain ClusterJ sources and binaries, and how to compile, install, and get started with ClusterJ.
Obtaining and Installing MySQL NDB Cluster Connector for Java. You can obtain the most recent NDB Cluster release, which includes ClusterJ, from downloads.mysql.com. The installation instructions given in NDB Cluster Installation also install ClusterJ.
Building and installing MySQL NDB Cluster Connector for Java from source.
You can build and install ClusterJ as part of
building and
installing NDB Cluster, which always requires you to
configure the build using the CMake option
WITH_NDBCLUSTER_STORAGE_ENGINE
(or
its alias WITH_NDBCLUSTER
).
A typical CMake command for configuring a build for NDB Cluster that supports ClusterJ might look like this:
cmake .. -DWITH_NDBCLUSTER=ON
The WITH_NDB_JAVA
option is enabled
by default, which means ClusterJ is be built together with NDB
Cluster by the above command. However, if CMake cannot find the
location of Java on your system, the configuration process is
going to fail; use the
WITH_CLASSPATH
option to provide the
Java classpath if needed. For information about other CMake
options that can be used, see
option_cmake_with_ndbcluster.
After configuring the build with CMake, run make and make install as you normally would to compile and install the NDB Cluster software.
MySQL NDB Cluster Connector for Java jar files.
Following the installation, these ClusterJ jar files can be
found in the folder share/java
under the
MySQL installation directory (which is
/usr/local/mysql
by default for Linux
platforms):
clusterj-api-
: This is the compile-time jar file, required for compiling ClusterJ application code.version
.jarclusterj-
: This is the runtime library required for executing ClusterJ applications.version
.jarclusterj-test-
: This is the ClusterJ test suite, required for testing your ClusterJ installation.version
.jar
Building ClusterJ with Maven
The source files for ClusterJ are configured as Maven projects, allowing easy compilation and installation using Maven. Assuming you have obtained the NDB Cluster source and already compiled and installed NDB Cluster and ClusterJ following the instructions given above, these are the steps to take:
-
Add the file path for the folder that contains the NDB client library (
libndbclient.so
) as a property namedndbclient.lib
to your local Mavensettings.xml
file (found in the local Maven repository, which is usually/home/
for Linux platforms). The client library is to be found under theusername
/.m2lib
folder in the NDB Cluster's installation folder. Ifsettings.xml
does not exist in your local Maven repository, create one. This is how a simplesettings.xml
file containing thendbclient.lib
property looks like:<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <profiles> <profile> <id>jni-library</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <ndbclient.lib>/NDB_Cluster_installation_directory/lib/</ndbclient.lib> </properties> </profile> </profiles> </settings>
-
Go to the build directory you created when compiling NDB Cluster (which is
bld
in the sample steps in Build the Distribution), and then to thestorage/ndb/clusterj
folder under it. Run themvn_install_ndbjtie.sh
script in the folder:./mvn_install_ndbjtie.sh
It installs
ndbjtie.jar
, which provides the JNI layer for ClusterJ and is required for building CluterJ. -
Install ClusterJ with Maven by running mvn install in the
storage/ndb/clusterj
directory:mvn install
This causes ClusterJ to be built, with the resulting
.jar
files installed in the local Maven repository.NoteYou can skip the tests that takes place towards the end of the installation process by adding the option
skipTests
to the command:mvn install -DskipTests
This prevents your installation from failing because you have not yet set up the testing environment.
Building ClusterJ with Maven in IDEs
Because the source files for ClusterJ are configured as Maven projects, you can easily import them into your favorite Maven-enabled IDEs, customize them, and rebuild them as needed by following these steps:
Make sure that your IDE's support for Maven is enabled. You might need to install a Maven plugin for the purpose.
Follow step 1 and 2 in Building ClusterJ with Maven, which make the ClusterJ source ready to be used with Maven.
-
Import ClusterJ as a Maven project. This is how to do it in some popular IDEs :
In NetBeans:
In the main menu, choose Open Project dialogue box appears
> . TheIn the Open Project dialogue box, browse to the
storage/ndb
folder under the build directory (see step 2 in Building ClusterJ with Maven); select theclusterj
folder, which has the Maven icon () beside it, and click . TheClusterJ Aggregate
project is imported, withClusterJ API
,ClusterJ Core
,ClusterJ Test Suite
,ClusterJ Tie
, andClusterJ Unit Test Framework
imported as subprojects under Modules.Work with the ClusterJ projects like you would with any other Maven projects in NetBeans. Any changes to the source code go into the source tree from which you compiled NDB Cluster to create the build directory.
In Eclipse:
In the main menu, choose Import dialogue box appears
> . TheIn the Import dialogue box, select > for import wizard and click . The Import Maven Projects dialogue box appears.
In the Import Maven Projects dialogue box, browse to the
storage/ndb
folder under the build directory (see step 2 in Building ClusterJ with Maven); select theclusterj
folder and click . Theclusterj-aggregate
project, as well as its subprojectsclusterj-api
,clusterj-core
,clusterj-test
,clusterj-tie
andclusterj-unit
, appear in the Maven Projects dialogue box. Click and then . All the ClusterJ projects are imported.Work with the ClusterJ projects like you would with any other Maven projects in Eclipse.