Skip to content

Compilation

Before following steps in this section, please ensure that the dependencies in Chapter 2 above are installed.

Before running make, copy the correct “makefile” for your system, depending if you are on Linux/Unix or MacOS. For example, if you were on Linux:

$ cd wolfcrypt-jni
$ cp makefile.linux makefile

If you are instead on Mac OSX:

$ cd wolfcrypt-jni
$ cp makefile.macosx makefile

Then compile the native C JNI source code with “make”. This will generate the native JNI shared library (libwolfcryptjni.so/dylib).

$ cd wolfcrypt-jni
$ make

To compile the Java sources, “ant” is used. There are several ant targets to compile either the JNI or JCE (includes JNI) packages, in either debug or release mode. Running regular “ant” will give usage options:

$ ant
...
build:
[echo] wolfCrypt JNI and JCE
[echo] ----------------------------------------------------------------------------
[echo] USAGE:
[echo] Run one of the following targets with ant:
[echo] build-jni-debug | builds debug JAR with only wolfCrypt JNI classes
[echo] build-jni-release | builds release JAR with only wolfCrypt JNI classes
[echo] build-jce-debug | builds debug JAR with JNI and JCE classes
[echo] build-jce-release | builds release JAR with JNI and JCE classes
[echo] ----------------------------------------------------------------------------

Use the build target that matches your needs. For example, if you want to build the wolfJCE provider in release mode, run:

$ ant build-jce-release

To run the JUnit tests, run ant test. This will compile only the tests that match the build that was done (JNI vs. JCE) and run those tests.

$ ant test

To clean the both Java JAR and native library, run:

$ ant clean
$ make clean

API Javadocs

Running ant will generate a set of Javadocs under the wolfcrypt-jni/docs/javadoc directory. To view the Javadoc index, open the following file in a web browser:

wolfcrypt-jni/docs/javadoc/index.html