Table of contents:

Manual download (without Maven)

Jack4j can be downloaded from SourceForge . You need two files from there - native library (compressed in ZIP format) and Java classes (compressed in JAR format). Unzip the native library archive before use.

When running your application that uses Jack4j, the JAR file must be in the classpath, and the native library must be available to native library loader - under Linux, it means that the $LD_LIBRARY_PATH variable must contain the directory under which the library is stored.

Using Jack4j with Maven

Jack4j is a Maven2 project, and is published in the central repository .

Adding dependencies

There are two artifacts needed for application that uses Jack4j - first of them contains Java classes (jar artifact, without classifier), second one contains native library (zip artifact, classifier "native-zip"). To add both artifacts as a dependency to your project, use this:

<dependencies>
  ...
  <dependency>
    <groupId>net.sf.jack4j</groupId>
    <artifactId>jack4j</artifactId>
    <version>VERSION</version>
  </dependency>
  <dependency>
    <groupId>net.sf.jack4j</groupId>
    <artifactId>jack4j</artifactId>
    <version>VERSION</version>
    <classifier>native-zip</classifier>
    <type>zip</type>
  </dependency>
  ...
</dependencies>

Packing Jack4j with your application

Use any strategy you want -- for example, you can unpack the dependency and add it into your JAR, or mark it as "provided" dependency. Just remember that the native library is needed at runtime, it must be unzipped before use, and must be placed into directory that the system uses to look up shared directories (under Linux, it means that the directory must be listed in $LD_LIBRARY_PATH).

Using Jack4j in unit tests

To use Jack4j in your tests, you will need to unpack the native zip, so that JVM can load the native library. Then, you must tell JVM where is the library located:

<build>
  <plugins>
    ...
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <executions>
        <execution>
          <id>unpack</id>
          <phase>generate-sources</phase>
          <goals>
            <goal>unpack</goal>
          </goals>
          <configuration>
            <artifactItems>
              <artifactItem>
                <groupId>net.sf.jack4j</groupId>
                <artifactId>jack4j</artifactId>
                <version>VERSION</version>
                <classifier>native-zip</classifier>
                <type>zip</type>
                <outputDirectory>${project.build.directory}/jack4j-native</outputDirectory>
              </artifactItem>
            </artifactItems>
          </configuration>
        </execution>
      </executions>
    </plugin>
    
    <plugin>
      <artifactId>maven-surefire-plugin</artifactId>
      <configuration>
        <forkMode>once</forkMode>
        <environmentVariables>
          <LD_LIBRARY_PATH>${project.build.directory}/native-lib</LD_LIBRARY_PATH>
        </environmentVariables>
      </configuration>
    </plugin>
    
    ...
  </plugins>
</build>

Building Jack4j from source

Requirements

You will need the following to compile Jack4j:

  • working Jack server

    The server should have all features available in Jack4j compiled in. At the time of writing this document, the version compatible with Jack4j was JACK 0.109.2.

  • Maven2 build tool , correctly set up

    Maven automatically downloads plugins and dependencies, that means that you will need access to the Internet to use it.

  • C++ compiler

    gcc compilation was tested on Linux; other compilers were not tested (yet)

  • Java SDK, at least version 1.5
  • Optionally, Subversion client

Downloading sources

To check-out the latest snapshot of Jack4j sources, use Subversion:

svn co https://jack4j.svn.sourceforge.net/svnroot/jack4j/trunk

To checkout specific release, use:

svn co https://jack4j.svn.sourceforge.net/svnroot/jack4j/tags/jack4j-VERSIONNUMBER

(replace VERSIONNUMBER with the version name).

Alternatively, you can download source tarball/zip from SourceForge .

Compiling and testing

To compile, go to the source directory and run: "mvn compile"

To run tests, ensure that JACK server is running, and run: "mvn test"

Other Maven goals such as "package" are also working, of course.