Skip to content

Commit

Permalink
Add some information about Java bindings. (rmind#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmind authored May 6, 2019
1 parent 912c569 commit b2175c4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The implementation is written in C99 and is distributed under the
2-clause BSD license.

Additionally, bindings are available for **Lua** and **Java**.
There is a specification to build an RPM package.
Specifications to build RPM and DEB packages are also provided.

## API

Expand Down Expand Up @@ -49,7 +49,9 @@ There is a specification to build an RPM package.
provide at least 4 or 16 bytes (depending on the address family). Returns
zero on success and -1 on failure.

## Lua example
## Examples

### Lua

```lua
local lpm = require("lpm")
Expand All @@ -67,6 +69,12 @@ local ret = acl:lookup(lpm.tobin("10.0.0.100"))
print(ret.val)
```

### Java

See [README](src/jni) how to build the JAR and the
[test case](src/jni/org/netbsd/liblpm/LPMTest.java) as example
how to use the Java API

## Packages

Just build the package, install it and link the library using the
Expand Down
8 changes: 5 additions & 3 deletions src/jni/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# This file is in the Public Domain.
#

CFLAGS= -std=gnu99 -O2 -g -W -Wextra -Werror -D_BSD_SOURCE
CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
CFLAGS+= -Wshadow -Wcast-qual -Wwrite-strings
CFLAGS+= -std=c99 -O2 -g -Wall -Wextra -Werror
CFLAGS+= -D_POSIX_C_SOURCE=200809L
CFLAGS+= -D_GNU_SOURCE -D_DEFAULT_SOURCE

CFLAGS+= -Wno-unused-parameter

ifeq ($(MAKECMDGOALS),tests)
DEBUG= 1
Expand Down
17 changes: 17 additions & 0 deletions src/jni/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# LPM library Java bindings

## Building

The below is an example of building on Debian 10. Set the `JAVA_HOME`
according to your JDK version and system.

```shell
$ uname -srv
Linux 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1 (2019-04-12)
$ sudo apt-get install openjdk-8-jre-headless openjdk-8-jdk-headless
...
$ cd liblpm/src/jni
$ JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 make test
```

This will produce the `liblpm.jar` file. Use it in your project.

0 comments on commit b2175c4

Please sign in to comment.