Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 1.21 KB

README.md

File metadata and controls

51 lines (36 loc) · 1.21 KB

JNI wrapper for V

V wrapper around the C Java Native Interface

This is Work-In-Progress - things will break and things will change.

You will need a working install of the V compiler and a working Java JDK environment (version >= 8).

Install

git clone https://github.com/larpon/jni.git ~/.vmodules/jni

Quick start

To use jni it is required to set the JAVA_HOME env variable to point to a valid Java install path that hosts the JNI you want to use.

export JAVA_HOME=/path/to/java/root

Desktop

To build the desktop example do:

cd ~/.vmodules/jni/examples/desktop/v_as_library
v run build_and_run.vsh

The build_and_run.vsh script is a simple helper for doing:

export JAVA_HOME=/detect/path/to/java/root
export LD_LIBRARY_PATH="$(pwd)":$LD_LIBRARY_PATH # Needed for Java to load the shared library
v -prod -shared libvlang.v
javac io/vlang/V.java
java io.vlang.V

Android

The jni module supports Java interoperability with both Desktop and Android platforms.

To build the Android example you'll need a working version of vab.

Then simply do:

./vab ~/.vmodules/jni/examples/android/toast