Skip to content
/ jni Public

V wrapper around the C Java Native Interface

License

Notifications You must be signed in to change notification settings

larpon/jni

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7f5d1c0 · Apr 9, 2025
Jun 23, 2022
Jan 17, 2024
Mar 14, 2021
Jan 16, 2024
Nov 12, 2024
Aug 30, 2021
Jan 27, 2021
Aug 21, 2024
Apr 9, 2025
Apr 9, 2025
Jan 16, 2024
Apr 9, 2025
Jan 17, 2024
Jan 27, 2021

Repository files navigation

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