Maven is now used to update the constants, build the Java code, call make to build the native library, and run all the tests. I have removed the "install" and "uninstall" targets; instead, the expectation will be that the JNI library will be placed somewhere on java.library.path and the JAR file will be used as usual (e.g. in a downstream Maven project, or placed on the classpath of your project). Since Maven is now running our tests, this eliminates the need to bundle test dependencies in `testdep`, and makes the project structured more like a typical Java project.
1.6 KiB
This documentation explains how to install the Java binding for Unicorn from source.
-
Follow
docs/COMPILE.md
in the root directory to compile the core to thebuild
directory.Note: by default, the Java binding native library will be built by statically linking to
../../build/libunicorn.a
, thereby removinglibunicorn
as a runtime dependency, but making the produced native librarylibunicorn_java
bigger.If you instead want to dynamically link against the installed
libunicorn
, changeLIBS=../../build/libunicorn.a
toLIBS=-lunicorn
inMakefile
. -
Install a JDK for your platform.
-
Install Maven: https://maven.apache.org/install.html.
-
Change directories into the java bindings and build the Maven package:
$ mvn package
This will automatically build and test the Unicorn Java bindings.
The bindings consist of the native JNI library (libunicorn_java.{so,dylib,dll}
)
and the Java JAR (target/unicorn-2.xx.jar
). You will need to have the native
library on java.library.path
and the JAR on your classpath.
The src/main/test/java
directory contains some sample code to show how to use Unicorn API.
samples
is a set of sample classes showcasing the various features of the Unicorn API,
while tests
is a set of JUnit tests for the API.
-
Sample_<arch>.java
: These show how to access architecture-specific information for each architecture. -
Shellcode.java
: This shows how to analyze a Linux shellcode. -
SampleNetworkAuditing.java
: Unicorn sample for auditing network connection and file handling in shellcode.